# Issue understanding variables and with\_items

**URL:** <https://forum.ansible.com/t/issue-understanding-variables-and-with-items/24143>\
**Category:** Ansible Project\
**Created:** [April 4, 2017, 5:11pm UTC](https://forum.ansible.com/t/issue-understanding-variables-and-with-items/24143 "2017-04-04T17:11:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gforster](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gforster/32/535_2.png) [@gforster](https://forum.ansible.com/u/gforster)\
**Post date:** [April 4, 2017, 5:11pm UTC](https://forum.ansible.com/t/issue-understanding-variables-and-with-items/24143/1 "2017-04-04T17:11:52Z")

</div>

I think my issue is that I’m trying to get with\_items to do too much. But when I use user.uniq instead of with\_items, I’m getting a similar error. I’m really not understanding what approach to take. Thanks,

Here is the task:

`

- name: Create New Version Directories in User’s Home Dir  
file: path={{ home\_path }}/home/{{ item.uniq }}/validator/{{ item }} mode=0755 owner={{ item.uniq }} group={{ group\_devel }} state=directory  
with\_items:
- “{{ user }}”
- “{{ validator\_ver }}”
- “{{ validator\_ver }}/log”
- “{{ validator\_ver }}/config”  
`

Here is the relevant var from the var/main.yml

`  
user:

- { name: “HeyYou”, uniq: “myself”, validator\_port: “1078” }  
`

Here is the error:  
`

TASK [netiq-validator : Create New Version Directories in User’s Home Dir] \*\*\*\*\*  
— before  
+++ after  
@@ -1,4 +1,4 @@  
{  
“path”: “/home/myself/validator/{u’validator\_port’: u’1078’, u’uniq’: u’myself’, u’name’: u’HeyYou’}”,

- “state”: “absent”

- “state”: “directory”  
}  
changed: [p-idm-bot1] =\> (item={u’validator\_port’: u’1078’, u’uniq’: u’myself’, u’name’: u’HeyYou’})  
fatal: [p-idm-bot1]: FAILED! =\> {“failed”: true, “msg”: “the field ‘args’ has an invalid value, which appears to include a variable that is undefined. The error was: ‘float object’ has no attribute ‘uniq’\n\nThe error appears to have been in ‘ansible/roles/netiq-validator/tasks/main.yml’: line 17, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Create New Version Directories in User’s Home Dir\n ^ here\n”}  
`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 5, 2017, 10:38am UTC](https://forum.ansible.com/t/issue-understanding-variables-and-with-items/24143/2 "2017-04-05T10:38:29Z")

</div>

I'm not sure I understand what you are trying to do, since the with\_items list is a mix of different data.

with\_items will in you code run the module file 4 times.  
1. First time with item = "{{ user }}"  
2. Second time with item = "{{ validator\_ver }}"  
3. Third time with item = "{{ validator\_ver }}/log"  
4. Last time with item = "{{ validator\_ver }}/config"

item.uniq will only be avaiable on the first run since that is the only one that contains the key.

So for owner you are probably looking for "{{ user.uniq }}" and remove the - "{{ user }}" form the list.
