I think you want {{ item.0.name }}

On Thu, Oct 13, 2016 at 2:21 PM, Slavek Jurkowski <[email protected]>
wrote:

> Thanks for the quick response. I think i’m going to just hack the name
> into the dict like so as i want to preserve the dict structure and this
> least bad way i see of doing that. My dict var is auto populated from
> another tool so it shouldn’t be hard for me to keep these in sync.
>
> Slavek
>
>
> 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
>
>
>
>
> On Oct 13, 2016, at 1:14 PM, Joanna Delaporte <[email protected]>
> wrote:
>
> Slavek,
>
> I converted my dicts to lists. :P It didn't take too long with some snappy
> regex in vim.
>
> Joanna
>
> On Thu, Oct 13, 2016 at 9:06 AM, Slavek Jurkowski <[email protected]>
> wrote:
>
>> Joanna,
>>
>> Did you find any solution to this? I'm facing the same issue and it sure
>> sucks!
>>
>> Thanks!
>>
>>
>> On Wednesday, June 29, 2016 at 1:43:39 PM UTC-5, Joanna Delaporte wrote:
>>>
>>> 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
>>>
>>>
>>> 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. I need just the username, eg
>>> the argument I want to pass is --users=user1. Is there a reason I cannot
>>> access it with item.0.key?
>>>
>>> My dict object looks like this:
>>> ---
>>> 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']
>>>
>>>
>>>
>> --
>> 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/to
>> pic/ansible-project/4jqKl1v69mI/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/ansible-project/52bb457e-6b09-4c66-b619-4cc0074a8eef%
>> 40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/52bb457e-6b09-4c66-b619-4cc0074a8eef%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
>
> Joanna Delaporte
> Linux Systems Administrator | Parkland College
> [email protected]
>
> --
> 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
> [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/CAG5Enc%2Bev%2BJCMrJ964oy1Gdao%
> 3DryBQ7Nywc06ppy4_%2Bx2Q0DVw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAG5Enc%2Bev%2BJCMrJ964oy1Gdao%3DryBQ7Nywc06ppy4_%2Bx2Q0DVw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/5E4118D1-611D-4D41-9447-1B8DC07F1665%40thejurks.com
> <https://groups.google.com/d/msgid/ansible-project/5E4118D1-611D-4D41-9447-1B8DC07F1665%40thejurks.com?utm_medium=email&utm_source=footer>
> .
>
> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CABnTgtVQ0hTO%3DT_7HrMi%3D__g%3Du_NBqbQ6c5N%3DMhctH6y5WPCaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to