# what's wrong here?

**URL:** <https://forum.ansible.com/t/whats-wrong-here/25015>\
**Category:** Ansible Project\
**Created:** [July 18, 2017, 6:31pm UTC](https://forum.ansible.com/t/whats-wrong-here/25015 "2017-07-18T18:31:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregory\_Edigarov](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gregory\_Edigarov](https://forum.ansible.com/u/Gregory_Edigarov)\
**Post date:** [July 18, 2017, 6:31pm UTC](https://forum.ansible.com/t/whats-wrong-here/25015/1 "2017-07-18T18:31:44Z")

</div>

- blockinfile:  
path: /etc/apache2/sites-enabled/“{{ item }}”.php.qarea.org.conf  
block: |  
  
AssignUserId “{{ item }}” “{{ item }}”  
  
insertbefore:   
with\_items:  
“{{ sites }}”

TASK [blockinfile] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/greg/projects/php-users.yaml:104  
fatal: [php]: FAILED! =\> {  
“failed”: true,  
“msg”: “the field ‘args’ has an invalid value, which appears to include a variable that is undefined. The error was: ‘item’ is undefined\n\nThe error appears to have been in ‘/home/greg/projects/php-users.yaml’: line 104, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - blockinfile:\n ^ here\n”  
}

sites variable is defined like this:

vars:  
sites:

- [site1.com](http://site1.com)
- [site2.com](http://site2.com)  
etc…

it seems like it doesn’t understand double reference to a variable in cycle like “{{ item }}” “{{ item }}”

what to do?  
thanks a lot in advance

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [July 19, 2017, 9:12am UTC](https://forum.ansible.com/t/whats-wrong-here/25015/2 "2017-07-19T09:12:48Z")

</div>

- does it work when your block contain a single "{{ item }}" ?  
- does it work when you "{{ sites }}" is on the same line as with\_items?

---

<div class="post-metadata">

**Author:** ![Mathias\_Ettinger](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mathias\_Ettinger](https://forum.ansible.com/u/Mathias_Ettinger)\
**Post date:** [July 19, 2017, 10:50am UTC](https://forum.ansible.com/t/whats-wrong-here/25015/3 "2017-07-19T10:50:38Z")

</div>

It seems like `with_items` is indented inside `blockinfile`, it should be at the same level:

- blockinfile:  
path: /etc/apache2/sites-enabled/“{{ item }}”.php.qarea.org.conf  
block: |  
  
AssignUserId “{{ item }}” “{{ item }}”  
  
insertbefore:   
with\_items: “{{ sites }}”
