# Ansible "block" error

**URL:** <https://forum.ansible.com/t/ansible-block-error/34974>\
**Category:** Ansible Project\
**Created:** [April 13, 2021, 3:04pm UTC](https://forum.ansible.com/t/ansible-block-error/34974 "2021-04-13T15:04:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keith\_Mills](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Keith\_Mills](https://forum.ansible.com/u/Keith_Mills)\
**Post date:** [April 13, 2021, 3:04pm UTC](https://forum.ansible.com/t/ansible-block-error/34974/1 "2021-04-13T15:04:14Z")

</div>

How do I troubleshoot the Ansible Error “block is not a valid attribute for a Play”? Or, is there a better attribute to use here?

Ansible Version:

ansible 2.9.18  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/home/keith/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible  
python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

Playbook:

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [April 13, 2021, 4:22pm UTC](https://forum.ansible.com/t/ansible-block-error/34974/2 "2021-04-13T16:22:55Z")

</div>

> How do I troubleshoot the Ansible Error “block is not a valid attribute for a Play”? Or, is there a better attribute to  
> use here?

Your code in your playbook should be inside "tasks:".

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

> Ansible Version:
> 
> ansible 2.9.18  
> config file = /etc/ansible/ansible.cfg  
> configured module search path = [u'/home/keith/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']  
> ansible python module location = /usr/lib/python2.7/site-packages/ansible  
> executable location = /usr/bin/ansible  
> python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
> 
> Playbook:
> 
> ---
> 
> - name: Get diagnostic info block  
> block:  
> - name: Get top process diagnostic info  
> script: library/diag\_top\_processes.ps1  
> failed\_when: false  
> changed\_when: false  
> register: diag\_top\_proc\_out
> 
> ```
> \- name: Get memory and pagefile usage diagnostic info
> script: library/diag\_memory\_and\_pagefile\.ps1
> failed\_when: false
> changed\_when: false
> register: diag\_mem\_page\_out
> 
> \- name: Get CPU info
> script: library/diag\_cpu\_info\.ps1
> failed\_when: false
> changed\_when: false
> register: diag\_cpu\_info\_out
> 
> \- name: Init diag message
> set\_fact:
> diag\_msg: &quot;Diagnostic information:&quot;
> proc\_info:
> &quot;\{\{ diag\_top\_proc\_out\.stdout|regex\_replace\(&#39;\\r\\n|\\n|\\r&#39;, &#39;&#39;\) \}\}&quot;
> cpu\_info: &quot;\{\{ diag\_cpu\_info\_out\.stdout\_lines | join\(&#39; &#39;\) \}\}&quot;
> 
> \- name: Add top process info
> set\_fact:
> diag\_msg: &quot;\{\{ \[diag\_msg, proc\_info\] | join\(&#39; &#39;\) \}\}&quot;
> 
> \- name: Add memory info
> set\_fact:
> diag\_msg:
> &quot;\{\{ \[diag\_msg, diag\_mem\_page\_out\.stdout\_lines\[0\]\] | join\(&#39; &#39;\) \}\}&quot;
> 
> \- name: Add CPU info
> set\_fact:
> diag\_msg:
> &quot;\{\{ \[diag\_msg, cpu\_info\] | join\(&#39; &#39;\) 
> 
> ```

}}"
