On Friday, 28 September 2018 08.38.02 CEST Lionel H wrote:
> Replying to my-self,
> 
> I managed somehow to make some progress, but now the issue is that it merge 
> the results like the following:
> 
> Given the following config:
> chains_config:
>     1:
>         foo: bar
>         configs:
>             - type: bridged
>               version: 0.2
>     2:
>         foo: baz
>         configs:
>             - type: routed
>               version: 1.0
> 
> chains = [1, 2]
> 
> And using that loop with debug: 
> - debug: msg="chain={{ item.0 }}, configs={{ item.1.type }}"
>   with_nested:
>     - "{{ chains }}"
>     - "{{ chains |map('extract', chains_config) |map(attribute='configs') 
> |list }}"
> 
> I have the following output:
> ok: [server] => (item=None) => {
>     "msg": "chain=1, configs=bridged"
> }
> ok: [server] => (item=None) => {
>     "msg": "chain=1, configs=routed"
> }
> ok: [server] => (item=None) => {
>     "msg": "chain=2, configs=bridged"
> }
> ok: [server] => (item=None) => {
>     "msg": "chain=2, configs=routed"
> }
> 
> Which is not really right as not bridged config is defined for chain 2 and 
> no routed is defined for chain 1.

I haven't understood what your are trying in your previous mails, but based on 
this one you are looking for this?

  - debug: msg="chain={{ item.key }}, configs={{ item.value.configs.0.type }}"
    with_dict: "{{ chains_config }}"

If you would like to use the chains it would be something like this

  - debug: msg="chain={{ item }}, configs={{ chains_config[item].configs.0.type 
}}"
    with_item: "{{ chains }}"


-- 
Kai Stian Olstad


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

Reply via email to