Wrong variable substituion in template

26 views
Skip to first unread message

Jonatas Baldin

unread,
Jan 25, 2016, 10:01:13 AM1/25/16
to Ansible Project
Hi, how are you guys?

I got a problem in variable substitution in one template. I don't know if I'm doing something wrong or it may be a bug.

Here's the deal:

I've got this playbook:
---
- hosts: server
  become: yes
  vars:
    agent_server: 127.0.0.1
  roles:
    - server
    - agent

- hosts: proxy
  become: yes
  vars:
    proxy_server: 192.168.53.10
    agent_server: 127.0.0.1
  roles:
    - proxy
    - agent

- hosts: agent
  become: yes
  vars:
    agent_server: 192.168.53.11
  roles:
    - agent

In one template inside agent/templates/agent.conf there's this line:
server: {{ agent_server }}

These vars are in /defaults with a default value of 192.168.53.10.

The problem is, after everything runs, the server host get the variables agent_server from agent host, the value of 192.168.53.11. It DOES NOT get the specified value of 127.0.0.1.

Can I put the same variable multiple times in a playbook, for different hosts with different values?

Thanks! 

____________________________
Jonatas Baldin

Jonatas Baldin

unread,
Jan 25, 2016, 10:01:13 AM1/25/16
to ansible...@googlegroups.com

Jonatas Baldin

unread,
Jan 25, 2016, 11:05:27 AM1/25/16
to ansible...@googlegroups.com
Btw, I already got what was happen. 

I was trusting the inventory file generated by Vagrant, but it was messing around with the SSH ports, and every time I created the environment it, it was changed.
Just bind the private_network IP address on the inventory file and it is working like a charm!

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0e94e375-9271-4f8a-804b-14ff4f97c329%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
____________________________
Jonatas Baldin
Reply all
Reply to author
Forward
0 new messages