Created
September 17, 2014 16:20
-
-
Save tgerla/c5b276e02b1ef83f9362 to your computer and use it in GitHub Desktop.
Ansible and NTP example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[us_east:children] | |
us_east_dmz_servers | |
us_east_db_servers | |
[us_east_dmz_servers] | |
server1 | |
[us_east_db_servers] | |
server2 | |
# These variables can also be specified in | |
# group_vars/us_east_dmz_servers | |
[us_east_dmz_servers:vars] | |
ntp_servers="10.212.1.128,10.212.129" | |
[us_east_db_servers:vars] | |
ntp_servers="10.212.1.123,10.212.124" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
tasks: | |
- name: Write the ntp config file | |
template: src=ntp.conf.j2 dest=/tmp/ntp.conf backup=yes | |
notify: restart ntp | |
handlers: | |
- name: restart ntp | |
service: name=ntpd state=restarted enabled=yes | |
notify: update time now | |
- name: update time now | |
shell: ntpdate -u {{ ntp_servers.split(',')[0] }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
driftfile /var/lib/ntp/drift | |
restrict default kod nomodify notrap nopeer noquery | |
restrict -6 default kod nomodify notrap nopeer noquery | |
restrict 127.0.0.1 | |
restrict -6 ::1 | |
{% for i in ntp_servers.split(',') %} | |
server {{ i }} iburst | |
{% endfor %} | |
includefile /etc/ntp/crypto/pst | |
keys /etc/ntp/keys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment