sounds like nics is an empty list, your first example is correct syntax,
the rest are not.

On Wed, Aug 12, 2015 at 12:27 PM, <lilfe...@cisco.com> wrote:

> Hi Guys,
>
> Thank you for the responses. I should have mentioned this - I had already
> tried several combinations (including the suggestion above) with and
> without nested {{ }}, but still can't get a working syntax. Please see
> below for some attempts and their results.
>
> Putting an example/note in the docs would be really helpful as well.
>
> Thanks,
> Lilian
>
> host# ansible-playbook test.yml --extra-vars "num=0"
>
> Format Attempt:
>          cvmip: "{{nics[num].ip}}"
> Result:
> TASK: [Static IP Case - Find out Static Overlay IP]
> ***************************
> fatal: [127.0.0.1] => One or more undefined variables: 'list object' has
> no attribute u'0'
>
> Format Attempt:
>          cvmip: "{{nics['num'].ip}}"
> Result:
> TASK: [Static IP Case - Find out Static Overlay IP]
> ***************************
> fatal: [127.0.0.1] => One or more undefined variables: 'list object' has
> no attribute 'num'
>
> Format Attempt:
>          cvmip: "{{nics}}"["{{num}}"].ip}}
> Result:
> ERROR: Syntax Error while loading YAML script, test.yml
>
>
>
>
> On Tuesday, August 11, 2015 at 6:35:06 PM UTC-7, Timothy Appnel wrote:
>>
>> That is a good way of thinking of explaining it in the context of Ansible
>> -- start Jinja, stop Jinja. At the same time, how would you have
>> represented this in a Jinja template? Jinja doesn't allow for nested
>> mustaches in any context that I am aware of.
>>
>> I'm sure a patch to the docs to make light of this would be appreciated.
>>
>>
>>
>> [image: photo]
>> Timothy Appnel
>> Senior Solutions Architect
>>
>> Ansible, Inc. *•* www.ansible.com
>>
>> On Tue, Aug 11, 2015 at 8:38 PM, Josh Smift <j...@care.com> wrote:
>>
>>> TA> Don't use nested mustaches.
>>>
>>> This should probably be a FAQ. :^) FWIW, what helped me understand this
>>> is
>>> that the mustaches aren't saying "here's a variable" (in which case you
>>> might think, incorrectly, that you need to put them around all variables
>>> all the time everywhere), but rather "start parsing this as Jinja", and
>>> that once you say that, it keeps happening until you close the mustaches
>>> (which means "stop parsing this as Jinja"). One of the things that
>>> happens
>>> when you're parsing as Jinja is that variables get expanded, but thinking
>>> of it as "start Jinja" and "stop Jinja" helped me keep it straight when I
>>> first started with this stuff, anyway.
>>>
>>>                                       -Josh (j...@care.com)
>>>
>>>
>>>
>>> This email is intended for the person(s) to whom it is addressed and may
>>> contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized
>>> use, distribution, copying, or disclosure by any person other than the
>>> addressee(s) is strictly prohibited. If you have received this email in
>>> error, please notify the sender immediately by return email and delete the
>>> message and any attachments from your system.
>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/21962.38250.656216.677376%40gargle.gargle.HOWL
>>> .
>>> 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+unsubscr...@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/ace73f52-96d6-47cc-92dc-fd067701e7d2%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/ace73f52-96d6-47cc-92dc-fd067701e7d2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Brian Coca

-- 
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+unsubscr...@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/CAJ5XC8k7Vgj2HbTdyvw%3Dr7OCc8%3DEsnAoTJasuJN45O8wAMOe-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to