I am preparing some Ansible scripts for a service that works in a 
master/slave setup. There is a single docker image for both but the 
master/slave behavior will be acquired after configuring some environment 
variables.

When i explicitly setup each container, this is roughly how my playbook 
would look:

 ---
- hosts: host1,host2
  gather_facts: yes
  tasks:
docker_container:
name: "{{prefix}}_container"
image: "{{image_name}}"
state: started
env:
M1: V1
M2: {{IP_address_of_the_other_one}}
when: master
docker_container:
name: "{{prefix}}_container"
image: "{{image_name}}"
state: started
env:
S1: SV1
S2: {{IP_address_of_the_other_one}}
when: slave







What i want to do is to automate this in my playbook where Ansible would 
automatically assign one value set to one host and second value set to the 
other one. This will help me reduce the number of variables a person has to 
configure. So how can i formulate a condition where i would apply M1 and M2 
for one host and S1 and S2 for the other one ?

-- 
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/f2d8cf8d-f44d-40c3-8477-2224af392da3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to