Hello.
Try use "{{myserver[location.dc][location.zone]}}"
пт, 26 апр. 2019 г., 1:36 'Mark Tovey' via Ansible Project <
[email protected]>:
>
>
> I have a dictionary structure that looks like the following:
>
>
>
> myservers:
>
> DC1:
>
> CORE: 10.10.10.20
>
> DMZ: 10.10.20.20
>
> DC2:
>
> CORE: 10.10.10.30.20
>
> DMZ: 10.10.10.40.20
>
> DC3:
>
> CORE: 10.10.50.20
>
> DMZ: 10.10.60.20
>
> DC4:
>
> CORE: 10.10.70.20
>
> DMZ: 10.10.80.20
>
>
> And another dictionary that looks like the following:
>
> location:
>
> address: 10.10.10.10
>
> dc: DC1
>
> net: 10.10.10.0
>
> bits: 24
>
> zone: CORE
>
>
> I want to do something like the following:
>
> - debug:
>
> msg: "myserver = myservers['{{location.dc}}']['{{location.zone}}']"
>
>
> and get back the message:
>
> myserver = 10.10.10.20
>
>
> But instead, I get:
>
> myserver = myservers['DC1']['CORE']
>
>
> I want to see the value stored at myservers['DC1']['CORE'], not the
> string "myservers['DC1']['CORE']".
>
> I have tried " {{ myservers['{{location.dc}}']['{{location.zone}}]
> }}", but YAML does not allow nested braces, so that fails. And I have
> tried many other variations, but they all fail too. I am stymied. How do
> I extract the information I want?
>
>
>
>
>
>
>
>
>
> --
> 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/0cb211b9-7c67-4b5a-b04b-2cd66db2fd24%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/0cb211b9-7c67-4b5a-b04b-2cd66db2fd24%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/CAO32mpRYongE%3D3F0jfOD51SsWc01fNZH8Pj%2BuNz%3DF6qviqH1MQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.