Matt,
I revisited this and I'm not sure what I did wrong before, but it worked!
Thanks for the tip.
On Thursday, January 22, 2015 at 1:57:47 PM UTC-5, Chip Selden wrote:
>
> Matt,
>
> Thanks, that's a good thought, but it returned the same error.
>
> On Thursday, January 22, 2015 at 1:37:19 PM UTC-5, Matt Martz wrote:
>>
>> Try:
>>
>> {{people[myperson].name}}
>>
>> On Thursday, January 22, 2015, Chip Selden <[email protected]> wrote:
>>
>>> Greetings,
>>>
>>> I'm trying to use a variable to determine which node in a dictionary to
>>> get information from. I will later want to use this for iterating over
>>> lists of variables so that I can use specific nodes in a dict without
>>> looping over all of them.
>>>
>>> I have the following vars:
>>> myperson: bob
>>> people:
>>> alice:
>>> name: alice
>>> age: 30
>>> bob:
>>> name: bob
>>> age: 30
>>>
>>> I using the following task to test the result:
>>> - name: Debug out myperson's name
>>> debug: msg="name = {{people.{{myperson}}.name}}"
>>>
>>> This returns the following error:
>>> template error while templating string: expected name or number
>>>
>>> Note the only way that I have gotten this to evaluate correctly is if I
>>> use the following task where I only need one set of braces:
>>> - name: Debug out myperson's name
>>> debug: var=people.{{myperson}}.name
>>>
>>> However, I cannot use this syntax in other cases (such as the shell or
>>> lineinfile modules). Is there some syntax for nesting variables in this way
>>> that I'm not aware of?
>>>
>>> Thanks,
>>> Chip
>>>
>>> --
>>> 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/f47bbc60-a904-4616-87d6-901ac1a07a83%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/ansible-project/f47bbc60-a904-4616-87d6-901ac1a07a83%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Matt Martz
>> @sivel
>> sivel.net
>>
>>
--
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/fd1c25cb-1c62-4160-99a8-1329f72072dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.