And how can I use a variable to select an index into a dictionary?
vars:
ind: 'ind1'
dict:
ind1:
value: 1
ind2:
value: 2
I'd like to get something like {{ dict.{{ ind }} }} (which obviously fails
...)
El sábado, 31 de mayo de 2014, 18:16:58 (UTC+2), Michael DeHaan escribió:
>
> "I'm struggling to find the best way to define a dictionary variable
> dynamically. "
>
> Sounds like you should just have a dictionary of values and use a variable
> to select an index into it, you don't really want to define the dictionary
> dynamically but pick an element.
>
>
>
> On Thu, May 29, 2014 at 2:59 PM, Steve Fox <[email protected]
> <javascript:>> wrote:
>
>> I'm struggling to find the best way to define a dictionary variable
>> dynamically. My goal is to define a dictionary with product versions as
>> keys and the latest revisions as values. That way I can define the path to
>> the latest build for each product version.
>>
>> It seems like a lookup plugin should be perfect, even though they're
>> required to return a list. I tried sending back the dictionary inside a
>> list, but that fails with
>>
>> "an unexpected type error occured. Error was sequence item 0:
>> expected string, dict found"
>>
>> I get this same error whether I use vars: or set_fact with complex
>> arguments.
>>
>> I then took a different approach and converted my lookup plugin to a
>> module which defines a specific fact. This worked, but unfortunately the
>> fact is scoped to each host, so the module has to run repeatedly. Is there
>> a better way?
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/f7033dd3-8efb-479f-afc5-914caeab48c4%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/f7033dd3-8efb-479f-afc5-914caeab48c4%40googlegroups.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/934d914c-a3ec-42dd-ba23-4edec7f87a76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.