Hello,
I'm trying to create an Ansible role, networking, to automate /etc/resolv.conf file. I created this role like below:
production
networking.yml
group_vars/
agroup
bgroup
roles/
networking/
tasks/main.yml
templates/resolv.conf.j2
In my resolv.conf.j2 file, I put variables in this file:
{% for item in nameserver %}
nameserver {{ item }}
{% endfor %}
The name servers will be different for different group systems.
In group_vars/agroup:
---
nameservers:
- 192.168.10.251
- 192.168.10.252
In group_vars/bgroup:
---
nameservers:
- 192.168.101.251
- 192.168.101.252
In playbook networking.yml:
---
- hosts: all
roles:
- networking
In production (inventory) file:
[agroup]
myserver
[bgroup]
myserver2
Here is command I want to use for play:
$ ansible-playbook -i production networking.yml -l myserver
$ ansible-playbook -i production networking.yml -l myserver2
Does above play use agroup defined nameservers for myserver, and bgroup defined nameservers for myserver2?
Thank you,
- Xinhuan