- add montreal and quebec to hosts file
[montreal]
ansiblemaster
ansible1
[quebec]
ansible2
- create group_vars folder with montreal and quebec
group_vars/montreal
ntp_server1: 2.pool.ntp.org
ntp_server2: 3.pool.ntp.org
dns_server: 8.8.8.8
group_vars/quebec
ntp_server1: 0.pool.ntp.org
ntp_server2: 1.pool.ntp.org
dns_server: 8.8.4.4
- take hardcoded files from files and put them in templates
templates/ntp.conf.j2
driftfile /var/lib/ntp/ntp.drift
server {{ ntp_server1 }}
server {{ ntp_server2 }}
templates/resolv.conf.j2
; generated by /sbin/dhclient-script
search us-west-2.compute.internal
nameserver {{ dns_server }}
- change copy modules for template in common role
- name: Configuration fichier ntp.conf - TEMPLATE
template: backup=yes src=ntp.conf.j2 dest=/etc/ntp.conf owner=root group=root mode=0644
notify: Restart ntpd
- name: Configuration fichier resolv.conf - TEMPLATE
template: backup=yes src=resolv.conf.j2 dest=/etc/resolv.conf owner=root group=root mode=0644
- run ansible with new template changes
ansible-playbook --private-key=/home/dave/ec2.pem -u ec2-user site.yml -s