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.
For more options, visit https://groups.google.com/d/optout.