FAILED! => {"failed": true, "msg": "'dict object' has no attribute 'key'"}
- name: Add users to groups
shell: 'ipa group-add-member {{item.1}} --users={{item.0.key}}'
with_subelements:
- '{{staff|default([])}}'
- 'extragroups'
- skip_missing: yes
---
staff:
user1:
uid:
firstname:
lastname:
comment: ""
gid:
shell: /bin/bash
passwordhash: ""
primarygroup:
extragroups: ['code']
user2:
uid:
firstname:
lastname:
comment: ""
gid:
shell: /bin/bash
passwordhash: ""
primarygroup:
extragroups: ['dm', 'code']
Here's my version: ansible 2.2.0 (devel 87928ff56b) last updated 2016/06/22 13:32:23 (GMT -500)I'm not sure if this is a bug, or misplaced syntax. When I attempt to use a dictionary, referencing the key of the dictionary and a subelement, I get the error
FAILED! => {"failed": true, "msg": "'dict object' has no attribute 'key'"}
Here is my task:
- name: Add users to groups
shell: 'ipa group-add-member {{item.1}} --users={{item.0.key}}'
with_subelements:
- '{{staff|default([])}}'
- 'extragroups'
- skip_missing: yes
The syntax I am aiming for is --users=user1. However, I am having trouble accessing the usernames with with_subelements. If I use item.0 instead of item.0.key, it tries to pass in the entire dictionary object rather than just the key, and the command spits back a "too many arguments" error, which is expected. Is there a reason I cannot access it with item.0.key?
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/52bb457e-6b09-4c66-b619-4cc0074a8eef%40googlegroups.com.--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/4jqKl1v69mI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
vars:
users:
bob:
name: bob
authorized_keys:
- "ssh-rsa a..."
- "ssh-rsa b..."
alice:
name: alice
authorized_keys:
- "ssh-rsa c..."
tasks:
- authorized_key: user=item.0.name key="{{ item.1 }}"
with_subelements:
- "{{ users }}"
- authorized_keys
To unsubscribe from this group and all its topics, send an email to ansible-proje...@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/CAG5Enc%2Bev%2BJCMrJ964oy1Gdao%3DryBQ7Nywc06ppy4_%2Bx2Q0DVw%40mail.gmail.com.
Slavek
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAG5Enc%2Bev%2BJCMrJ964oy1Gdao%3DryBQ7Nywc06ppy4_%2Bx2Q0DVw%40mail.gmail.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+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5E4118D1-611D-4D41-9447-1B8DC07F1665%40thejurks.com.
Slavek
To unsubscribe from this group and all its topics, send an email to ansible-proje...@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/52bb457e-6b09-4c66-b619-4cc0074a8eef%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/4jqKl1v69mI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@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/CAG5Enc%2Bev%2BJCMrJ964oy1Gdao%3DryBQ7Nywc06ppy4_%2Bx2Q0DVw%40mail.gmail.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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
---
interfaces: lo0: addresses: - address: 10.1.1.1 mask: 32 - address: 10.1.1.2 mask: 32 secondary: True mode: layer3 mgmt0: addresses: - address: 10.2.1.1 mask: 25 vrf: management mode: layer3 Ethernet1/16: addresses: - address: 10.3.1.1 mask: 31 mode: layer3 neighbor: name: switch-b interface: Ethernet1/1