debug: msg="Add user {{ item.key }} password {{ item.pass }}"
with_items:
- "{{ alice }}"
I am not able to figure out how to get the user name, ie "alice" as item.key is not valid. I think this is because using "{{ alice }}" does not preserve the name. Does anyone know how I can structure this? I've tried putting them all under users, but with_items: users.alice does not work.
Thanks in advance for any help. The docs do not seem to cover this and I've Googled Ansible arrays and dicts to the point where I'm not finding any new pages.
Michael Bushey
unread,
Oct 9, 2014, 7:56:01 PM10/9/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Please ignore the second mail: under bob
mvermaes
unread,
Oct 10, 2014, 2:20:11 AM10/10/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Thanks for your response Michael. I've already read through that page
a few times. It does not work for me because I need an array of users,
and then I need to be able to select which user have access to each
class of server. This method would give every user access to every
machine. I need to be able to specify something like with items -
users.alice - users.bob and not have carol included.
- name: Add user
debug: msg="Add user {{ item.key }} password {{ item.value.pass }}"
with_dict: users
when: item.key in allowed_users_host1
> 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-proje...@googlegroups.com.
--
Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno
Adam Heath
unread,
Oct 10, 2014, 12:36:05 PM10/10/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
- name: foo
shell: echo "{{ users[item].name }}"
with_items:
- alice
- bob
Michael Bushey
unread,
Oct 10, 2014, 2:51:50 PM10/10/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible-project
Awesome! Thank you so much for your responses Michael, Brian, and
Adam. Both solutions from Brian and Adam work, thank you! If any of
you get to Los Angeles I owe you a drink!