Hi,
I am writing an inventory that contains 3 groups of hosts, and each of them have their own host specific variables. It looks like this:
[abc]
10.10.0.101
10.10.0.102
[abc:vars]
dest_path=/home/wwwroot/abc
port=4100
appname=abc
[efg]
10.10.0.10
10.10.0.11
[efg:vars]
dest_path=/home/wwwroot/efg
port=4100
appname=efg
[xyz]
10.10.0.10
10.10.0.11
[xyz:vars]
dest_path=/home/wwwroot/xyz
port=3001
appname=xyz
I run a test playbook, and always get the wrong variables. the playbook looks:
---
- hosts: "{{ target_hosts }}"
user: webapps
tasks:
- name: test vars
debug: msg="{{ target_hosts }} has name {{ appname }} and port {{ port }} and {{ dest_path }}"
and I run it like this: ansible-playbook -i inventory test.yml -e "target_hosts=efg". I tried with all the 3 groups, but it always give me the same anwser: "prd has name efg and port 4100 and /home/wwwroot/efg".
Ansible: 1.9.2
OS: centos 6.2
Please help!
Thanks!