I need to set some variables that are the same no matter the client, and other variables need to be set conditionally based on values from Ansible facts. Basically I need an if/else case statement. What is the correct way to do this?
Some simple examples can be found here (http://docs.ansible.com/ansible/latest/playbooks_conditionals.html#conditionals) but this doesn't cover else conditions, and if I remove the second instance of VAR4, and put in condition that is not met, it still sets VAR4, when the match doesn't exist, so it seems like the "when" is not being evaluated. --- - name: Playbook Name hosts: all gather_facts: yes tasks: - name: Set variables vars: VAR1: 5 VAR2: 10 VAR3: 0 VAR4: 100 when: (ansible_some_fact == "some_value1") or (ansible_some_fact == "some_value2") VAR4: 200 when: (ansible_some_fact == "some_value3") or (ansible_some_fact == "some_value4") -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bafd7316-db91-47ec-98ee-2f71bc4005aa%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
