Hi All,
I have a playbook which copy application.proprties with db.username and db.password.
I have qa env and qa1 is a cluster with app and ui server. The hosts file (hosts.qa) is as per the best practises mentioned in docs.ansible.com site. I have similar hosts file for dev ( hosts.dev )
I have group_vars file for qa and qa1 with db.usernamd and db.password values. Same for dev and dev1 groups
>ansible-playbook -i inventory/hosts.qa --limit qa1 site.yml
When I run the playbook, with --limit qa1, the application properties template is not updated with qa1 group_vars file values, instead it has "qa" as db_username and db_password. The same works fine for --limit dev1
---
- hosts: appservers
remote_user: '{{ remote_user }}'
sudo: True
tasks:
- name: configure application properties
template: src=templates/application.properties.j2 dest=/tmp/application.properties
owner=root group=root mode=744
templates/application.properties
# {{ ansible_managed }}
#Database Configuration
db.username={{ db_username }}
db.password={{ db_password }}
inventory/hosts.dev
[dev1-appserver]
xyz.com
[dev1-uiserver]
abc.com
[appservers:children]
dev1-appserver
[dev1:children]
dev1-appserver
dev1-uiserver
inventory/hosts.qa
[qa1-uiserver]
123.com
[qa1-appserver]
567.com
[qa:children]
qa1-appserver
qa1-uiserver
[appservers:children]
qa1-appserver
[qa1:children]
qa1-appserver
qa1-uiserver
[uiservers:children]
qa1-uiserver
group_vars/qa
# variables related to the qa environment
db_username: qa
db_password: qa
group_vars/qa1
# variables related to the qa environment
db_username: qa1
db_password: qa1
group_vars/dev1
# variables related to the dev1 environment
db_username: dev1
db_password: dev1