# How to use block module with With\_items clause with result.stdout\_lines ?

**URL:** <https://forum.ansible.com/t/how-to-use-block-module-with-with-items-clause-with-result-stdout-lines/26127>\
**Category:** Ansible Developer\
**Created:** [November 24, 2017, 4:10pm UTC](https://forum.ansible.com/t/how-to-use-block-module-with-with-items-clause-with-result-stdout-lines/26127 "2017-11-24T16:10:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saurabh](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Saurabh](https://forum.ansible.com/u/Saurabh)\
**Post date:** [November 24, 2017, 4:10pm UTC](https://forum.ansible.com/t/how-to-use-block-module-with-with-items-clause-with-result-stdout-lines/26127/1 "2017-11-24T16:10:44Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 24, 2017, 5:07pm UTC](https://forum.ansible.com/t/how-to-use-block-module-with-with-items-clause-with-result-stdout-lines/26127/2 "2017-11-24T17:07:00Z")

</div>

Block is not a module, it is a Ansible keyword, - block can be used  
anywere tasks go, not inside a task declaration as you have above.  
It is designed to contain tasks and group keywords for them as well as  
allow error handling, not sure what you are trying to do with it  
inside a debug statement.

---

<div class="post-metadata">

**Author:** ![Saurabh](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Saurabh](https://forum.ansible.com/u/Saurabh)\
**Post date:** [November 24, 2017, 5:25pm UTC](https://forum.ansible.com/t/how-to-use-block-module-with-with-items-clause-with-result-stdout-lines/26127/3 "2017-11-24T17:25:36Z")

</div>

Thank brian for correcting me.

- hosts: localhost

- tasks:

- name: checking the issue  
shell: echo {{ item }} | grep -w name | wc -l  
register: var1  
with\_file:

- test.txt

- debug:  
var: {{ item.stdout }}  
when: item.stdout != 0  
with\_items: “{{ var1.results }}”

But I’m not able to get count value in var.
