[ansible-project] Re: Nested variable

2018-05-24 Thread Jordan Borean
ahh yes I should have seen you just wanted a nested var, just an FYI ~ is similar to + but coerces the variable to a string so you don't have to do that yourself. Usually + works but ~ is safer. Thanks Jordan -- You received this message because you are subscribed to the Google Groups

[ansible-project] Re: Nested variable

2018-05-24 Thread David Villasmil
Hey Jordan, Thanks for replying! There were "`" missing, worked beautifully after that! - set_fact: hosted_zone_id: "{{ dns_results | json_query('HostedZones[?Name==`' ~ hosted_zone_name ~ '.`].[Id]') | regex_replace('/hostedzone/', '') }}" "~" escapes it, so there's no need to do a

[ansible-project] Re: Nested variable

2018-05-23 Thread Jordan Borean
Try this - set_fact: hosted_zone_id: "{{ dns_results | json_query('HostedZones[?Name==' ~ lookup('vars', hosted_zone_name) ~ '].[Id]') | regex_replace('/hostedzone/', '') }}" You need to escape outside of the quoted arg of json_query and then run the lookup. Note I haven't tested this

[ansible-project] Re: Nested variable

2018-05-23 Thread David Villasmil
Spoke too soon... That doesn't work either... On Wednesday, May 23, 2018 at 10:04:16 PM UTC+2, David Villasmil wrote: > > Hello guys, > > > I've got this set_fact: > > hosted_zone_id: "{{ dns_results | > json_query('HostedZones[?Name==`mydomain.com.`].[Id]') | regex_replace > ('/hostedzone/',

[ansible-project] Re: Nested variable

2018-05-23 Thread David Villasmil
Solved! - set_fact: hosted_zone_id: "{{ dns_results | json_query('HostedZones[?Name==`(lookup('vars', hosted_zone_name)).`].[Id]') | regex_replace ('/hostedzone/', '') }}" For future reference. Thanks David On Wednesday, May 23, 2018 at 10:04:16 PM UTC+2, David Villasmil wrote: > >