0

Pseudocode:

If env is de, set variable name to hello else if env is prod, set variable name to bye.

I tried https://serverfault.com/questions/715769/ansible-change-default-value-according-to-a-condition

 - name: setting variable
   set_fact: name="hello"
   when: "{{ env }}" == "de"

 - name: setting variable
   set_fact: name="bye"
   when: "{{ env }}" == "prod"

ERROR! The default/main.yml file for role 'trial' must contain a dictionary of variables

Community
  • 1
  • 1
unknown
  • 15
  • 3

1 Answers1

0

As per my requirement, it needs to be done in role.So it is done as follows:

name: "{% if env == 'de' %}hello{% elif env == 'prod' %}bye{% endif %}"

unknown
  • 15
  • 3