Ansible - How attribute 2 value in one variable

8 views
Skip to first unread message

Karther

unread,
Nov 21, 2019, 5:29:24 AM11/21/19
to Ansible Project
Hello guy !! :)

I have any problem, can you help me please ?

I have 2 remote hosts, and i must deploy one template file.

The problem is i want one variable for one host and not for the both, exemple :

The content of my file template :

{{ my_ip_addr_host }}

somevalue=toto
somevalue1=toto2
...

I want when i deploy this template,on my host 1 {{ my_ip_addr_host }} get value 10.10.10.1 and when i deploy this template on my host 2 {{ my_ip_addr_host }} get value 10.10.10.2

I deploy on the same groupe [my_groupe] so the same environnement.

How resolve this problem please community ansible ???

Thank you very much !!! :)

Regards,

Karther

Kai Stian Olstad

unread,
Nov 21, 2019, 6:02:35 AM11/21/19
to ansible...@googlegroups.com
On 21.11.2019 11:29, Karther wrote:
> I want when i deploy this template,on my host 1 {{ my_ip_addr_host }}
> get
> value 10.10.10.1 and when i deploy this template on my host 2 {{
> my_ip_addr_host }} get value 10.10.10.2

This is covered in Ansible documentation and called host_vars
https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages