conditional statements should not include jinja2 templating delimiters

244 views
Skip to first unread message

Hearn, Stan J.

unread,
Mar 3, 2023, 4:15:47 PM3/3/23
to ansible...@googlegroups.com

I have this when clause that contains a variable named agent_host and I can't determine how to rewrite it to remove the mustaches.  The logic works, however I get the warning.

 

    when: "'Linked to: {{ agent_host }}' not in nessus_link_status.stdout"

 

[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: 'Linked to: {{ agent_host }}' not in nessus_link_status.stdout

 

Thanks,

Stan

 

ironma...@gmail.com

unread,
Mar 3, 2023, 4:22:47 PM3/3/23
to ansible...@googlegroups.com

when: "'Linked to: agent_host' not in nessus_link_status.stdout"

 

The above works for me.

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/PH0PR10MB559317CE2B6196CA9289334CF0B39%40PH0PR10MB5593.namprd10.prod.outlook.com.

Richard Megginson

unread,
Mar 3, 2023, 4:30:46 PM3/3/23
to ansible...@googlegroups.com
Not sure how that would work.  This should work

when: "'Linked to: ' ~ agent_host not in nessus_link_status.stdout"

Another way to do this is to define a local var

vars:
  __str: "Linked to: {{ agent_host }}"  # not sure if the quotes are strictly necessary - I default to using quotes when the string contains ":"
when: __str not in nessus_link_status.stdout


Reply all
Reply to author
Forward
0 new messages