need help on assigning a variable when string contains

20 views
Skip to first unread message

Sridhar Sambu

unread,
Jun 21, 2021, 11:42:12 AM6/21/21
to Ansible Project

- name: abc
  set_fact:
      Var1: "TestVarable"
  when: "{{'prod' in env}}"

I will pass env as prod so it should pick var1 as Testvariable.

Please help on correct syntax

Stefan Hornburg (Racke)

unread,
Jun 21, 2021, 12:59:35 PM6/21/21
to ansible...@googlegroups.com
Hello Sridhar,

the when: condition is always evaluated as Jinja, so remove the curly braces:

when: "'prod' in env"

Regards
Racke

>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8504deed-414a-4fc9-b28e-e3c2c05192a7n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/8504deed-414a-4fc9-b28e-e3c2c05192a7n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

Sridhar Sambu

unread,
Jun 21, 2021, 2:45:21 PM6/21/21
to Ansible Project

Thank you
Reply all
Reply to author
Forward
0 new messages