Syntax Issues for When Conditional

42 views
Skip to first unread message

Mark Huang

unread,
Aug 17, 2017, 11:18:04 AM8/17/17
to Ansible Project
Hi,

What is the proper syntax for trying to do something like this? It works fine but it gives me a warning that says not to use templating delimiters.

when: "{{ customer }}.aws_cloud_formation_state == 'present'"

I have tried just doing 

when: customer.aws_cloud_formation_state == 'present'

but that just goes into the customer dictionary looking for aws_cloud_formation. I would like to take a variable 'customer' and use it as the conditional. It works fine, but what is the correct syntax for getting it to work without giving a warning.

Thank you!
Mark


Kai Stian Olstad

unread,
Aug 18, 2017, 4:03:23 PM8/18/17
to ansible...@googlegroups.com
You need to use vars

when: vars[customer].aws_cloud_formation_state == 'present'

--
Kai Stian Olstad

Mark Huang

unread,
Aug 18, 2017, 5:06:42 PM8/18/17
to Ansible Project, ansible-pr...@olstad.com
That did the trick! 

Thank you!
Reply all
Reply to author
Forward
0 new messages