Bug in with_nested and registered variables?

8 views
Skip to first unread message

Patrick Laimbock

unread,
May 3, 2016, 1:11:43 PM5/3/16
to Ansible Project
Hi,

Earlier today on irc I heard that the snippet below not working might be
a bug. Being new to Ansible and not wanting to waste the developers time
I'd appreciate a confirmation that this is indeed a bug before filing it.

---

- hosts: localhost
gather_facts: no

vars:
my_users:
- usr: patrick
base: /home/
- usr: nonexistinguser
base: /home/

my_dirs:
- dir1
- dir1/dir2/dir3

tasks:
- name: check if my_users exist
shell: /usr/bin/getent passwd {{item.usr}} | /usr/bin/wc -l | tr
-d ' '
register: user_exists
with_items:
- "{{my_users}}"

- name: create dirs in my_user's home
file:
dest: "{{item.item.base}}{{item.item.usr}}/{{item[1]}}"
owner: "{{item.item.usr}}"
group: "{{item.item.usr}}"
mode: 0755
state: directory
recurse: yes
with_nested:
- "{{user_exists.results}}"
- "{{my_dirs}}"
# when: item.stdout == "1"


TASK [create dirs in my_user's home] **************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "'list object'
has no attribute 'item'"}

If it's not a bug then I'd love to hear how to make this work (including
with when:... enabled).

Thanks,
Patrick
Reply all
Reply to author
Forward
0 new messages