Dimitar Hristov
2015-07-15 11:33:25 UTC
Hi Guys,
I get an error when I run a playbook, which aims to create new users and
set authorized keys for them. The error:
TASK: [create new users]
******************************************************
fatal: [testvm1] => with_items expects a list or a set
fatal: [testvm2] => with_items expects a list or a set
Here's a part of the playbook (the first task fails):
- name: create new users
user: name={{ item.name }} group=wheel append=yes
password={{user_password}}
with_items: "{{users}}"
- name: set pub keys
authorized_key: "user={{ item.0.name }} key='{{ lookup('file',
item.1) }}'"
with_subelements:
- users
- authorized
- name: set pass expiration
command: /usr/bin/chage -d 0 {{ item.name }}
with_items: "{{users}}"
Here's the var file:
---
wheelsregex: # *%wheel *ALL=\(ALL\) *ALL
user_password: 12345678
users:
- name: test
authorized:
- /etc/ansible/add_users/files/test.pub
- name: test1
authorized:
- /etc/ansible/add_users/files/test1.pub
- name: test2
authorized:
- /etc/ansible/add_users/files/test2.pub
Any idea where's my mistake? I saw that it might be related to ansible
version, so mine is 1.9.2.
Regards,
Dimitar
I get an error when I run a playbook, which aims to create new users and
set authorized keys for them. The error:
TASK: [create new users]
******************************************************
fatal: [testvm1] => with_items expects a list or a set
fatal: [testvm2] => with_items expects a list or a set
Here's a part of the playbook (the first task fails):
- name: create new users
user: name={{ item.name }} group=wheel append=yes
password={{user_password}}
with_items: "{{users}}"
- name: set pub keys
authorized_key: "user={{ item.0.name }} key='{{ lookup('file',
item.1) }}'"
with_subelements:
- users
- authorized
- name: set pass expiration
command: /usr/bin/chage -d 0 {{ item.name }}
with_items: "{{users}}"
Here's the var file:
---
wheelsregex: # *%wheel *ALL=\(ALL\) *ALL
user_password: 12345678
users:
- name: test
authorized:
- /etc/ansible/add_users/files/test.pub
- name: test1
authorized:
- /etc/ansible/add_users/files/test1.pub
- name: test2
authorized:
- /etc/ansible/add_users/files/test2.pub
Any idea where's my mistake? I saw that it might be related to ansible
version, so mine is 1.9.2.
Regards,
Dimitar
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/76803881-f19a-4f47-a9bc-374a62a39672%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/76803881-f19a-4f47-a9bc-374a62a39672%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.