0

Team, I have two vars that map to two environments. I want to use them in playbook but only one value should be applied based on env playbook runs on.

ex:

var = test1 > should be loaded when env1
var = test2 > should be loaded when env2

any hint how can i achieve this in ansible?

I want to write my task in such a way that this variables var carries test1 value when it is run on env1 and vice versa. is there a login I can use at task level? my task is below and when am running my playbook on clusterA it should use var=test1 and when running on clusterB it should use var=test2

    - name: Add persistent ddn volume
  mount:
    path: "{{ lustre_client_path }}"
    src: "{{ var }}"
    fstype: lustre
    state: mounted
AhmFM
  • 119
  • 5
  • 1
    I suggest you read [Where to set an ansible variable](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable) and [How to build your inventory](https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html). – Zeitounator May 27 '22 at 15:44

1 Answers1

-1

Actually I figured out. I just had to create a separate file and called it configs.yml and place it in each cluster env playbook directly. This worked. So based on env is now loading.

AhmFM
  • 119
  • 5