Hi all,
I'm trying to work with vars in a vars file inside a role, and I'm unable to make it work. I'm working from
http://docs.ansible.com/ansible/playbooks_loops.html#standard-loops. Any pointers on what I'm doing wrong would be much appreciated.
I'm using 2.1.0 from Git on Debian.
If I have the following task in my role, it works as expected:
---
- name: Add groups
group: name={{ item.name }} gid={{ item.gid }} state=present
with_items:
- { name: 'g1', gid: '1010' }
- { name: 'g2', gid: '1011' }
However, if I try and use the vars in roles/rolename/vars/mail.yml and modify my role, I get the following error:
fatal: [myhost]: FAILED! => {"failed": true, "msg": "'unicode object' has no attribute 'gid'"}
If I remove the gid={{{ item.gid }} part of my task, then the message changes to
fatal: [myhost]: FAILED! => {"failed": true, "msg": "'unicode object' has no attribute 'name'"}
tasks/groups.yml
---
- name: Add groups
group: name={{ item.name }} gid={{ item.gid }} state=present
with_items: "{{groups}}"
vars/main.yml
groups:
- { name: 'g1', gid: '1010' }
- { name: 'g2', gid: '1011' }
Thanks!