I knew it was going to be simple, although I thought I tried that one too.
But that got it.
Thanks!
--------------------------------------------------------------------------------------------------------------------------
[Description: cid:[email protected]]Mark Tovey - UNIX Engineer
DSV<http://www.dsv.com/> | 110 N Marine Dr. | Bldg 1 | Portland | Oregon |
97217 | USA
[email protected]<mailto:[email protected]> | +1 503 222-5546
From: [email protected] <[email protected]> On
Behalf Of ??????? ???????
Sent: Thursday, April 25, 2019 11:50 AM
To: [email protected]
Subject: Re: [ansible-project] Complex dictionary access
Hello.
Try use "{{myserver[location.dc][location.zone]}}"
пт, 26 апр. 2019 г., 1:36 'Mark Tovey' via Ansible Project
<[email protected]<mailto:[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]<mailto:[email protected]>.
To post to this group, send email to
[email protected]<mailto:[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://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F0cb211b9-7c67-4b5a-b04b-2cd66db2fd24%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=02%7C01%7Cmark.tovey%40dsv.com%7C810a308425474a928b1908d6c9aee375%7C4a90c23a3ece4ef2b857522f23b8204c%7C0%7C0%7C636918150307308514&sdata=gwpM3quA35Alga53Y13FnTkMn6uuFkiwMDmVuEOEp0A%3D&reserved=0>.
For more options, visit
https://groups.google.com/d/optout<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Foptout&data=02%7C01%7Cmark.tovey%40dsv.com%7C810a308425474a928b1908d6c9aee375%7C4a90c23a3ece4ef2b857522f23b8204c%7C0%7C0%7C636918150307308514&sdata=nv9Wopo3vbOcZeropxhaJA1SRA56KxsQ1S390t7vtsU%3D&reserved=0>.
--
You received this message because you are subscribed to a topic in the Google
Groups "Ansible Project" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/ansible-project/bLYL1SGByK4/unsubscribe<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Ftopic%2Fansible-project%2FbLYL1SGByK4%2Funsubscribe&data=02%7C01%7Cmark.tovey%40dsv.com%7C810a308425474a928b1908d6c9aee375%7C4a90c23a3ece4ef2b857522f23b8204c%7C0%7C0%7C636918150307318523&sdata=rbZGvoHNqAQc25ollswlAhkJGb%2F%2BF4NhN5y49GtJR2A%3D&reserved=0>.
To unsubscribe from this group and all its topics, send an email to
[email protected]<mailto:[email protected]>.
To post to this group, send email to
[email protected]<mailto:[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<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCAO32mpRYongE%253D3F0jfOD51SsWc01fNZH8Pj%252BuNz%253DF6qviqH1MQ%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=02%7C01%7Cmark.tovey%40dsv.com%7C810a308425474a928b1908d6c9aee375%7C4a90c23a3ece4ef2b857522f23b8204c%7C0%7C0%7C636918150307318523&sdata=KRpviIx3iUBsAkoClNyX4VpkJsUTvPqFpI9bIhZ3s0E%3D&reserved=0>.
For more options, visit
https://groups.google.com/d/optout<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Foptout&data=02%7C01%7Cmark.tovey%40dsv.com%7C810a308425474a928b1908d6c9aee375%7C4a90c23a3ece4ef2b857522f23b8204c%7C0%7C0%7C636918150307328531&sdata=YpuazC6EDouCsO%2B%2FGJ0dcG9msT%2BmjIY5tMkLfJYuwiY%3D&reserved=0>.
--
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/AM5PR0602MB2771725A9E4C36031C09E2F09E3D0%40AM5PR0602MB2771.eurprd06.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.