Thanks, I was able to solve it using {{ ansible_eth0.ipv4.address }}.
However your link was very helpful in understanding how the variables work.
On Wednesday, 27 September 2017 15:40:57 UTC+5:30, Mauricio Tavares wrote:
>
> On Wed, Sep 27, 2017 at 6:00 AM, Parth Gandhi <[email protected]
> <javascript:>> wrote:
> > 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,
> > Parth
> >
> > --
> > 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] <javascript:>.
> > To post to this group, send email to [email protected]
> <javascript:>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/6509f789-02d5-4380-9a90-13dea10338be%40googlegroups.com.
>
>
> > For more options, visit https://groups.google.com/d/optout.
>
--
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/5deeaeba-3360-4dbc-9efb-40295edc08a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.