Hi,
I need to pass conditional value based on the host in the same group to environment variable in playbook. IS there a way to do it?
Here is the use case. I have a host file with a group having 2 servers
hosts:
[rancher]
hostA
hostB
rancher_create.yaml:
- hosts: xyz
docker_container:
image: xyz
env:
IP: {{ hostA_IP }}
the IP environment variable should take host A ip for HostA and hostB ip for HostB. Both the servers are used for same service in cluster and for cluster to setup there is a need to pass the individual IP to the docker container cmd.
Thanks,
Parth
Hi,
I need to pass conditional value based on the host in the same group to
environment variable in playbook. IS there a way to do it?
Here is the use case. I have a host file with a group having 2 servers
hosts:
[rancher]
hostA
hostB
rancher_create.yaml:
- hosts: xyz
docker_container:
image: xyz
env:
IP: {{ hostA_IP }}
the IP environment variable should take host A ip for HostA and hostB ip
for HostB. Both the servers are used for same service in cluster and for
cluster to setup there is a need to pass the individual IP to the docker
container cmd.
http://docs.ansible.com/ansible/latest/intro_inventory.html#host-variables
Thanks, I was able to solve it using {{ ansible_eth0.ipv4.address }}. However your link was very helpful in understanding how the variables work.