Signed-off-by: Abdelaziz Raji <abdelaziz.raji@gmail.com>
@@ -0,0 +1,2 @@
+ntp deployment using ntpd and configuration basic template.
+handler will restart and wait for at least one server to sync .
@@ -0,0 +1,14 @@
+---
+- name: restart ntpd
+ service: name=ntpd state=restarted enabled=yes
+
+- name: sync clocks
+ shell: ntpdc -np
+ register: ntp_clock
+ until: ntp_clock.stdout.find('*') > -1
+ retries: 10
+ delay: 60
@@ -0,0 +1,19 @@
+- name: deploy ntpd
+ yum: name=ntp state=present
+- name: deploy ntpdate
+ yum: name=ntpdate state=present
+# ntp server
+- name: update ntp servers
+ template:
+ src: ntp.conf.j2
+ dest: /etc/ntp.conf
+ owner: root
+ group: root
+ mode: u=rw,g=r,o=r
+ backup: yes
+ notify:
+ - restart ntpd
+ - sync clocks
@@ -0,0 +1,16 @@
+driftfile /var/lib/ntp/drift
+restrict default nomodify notrap nopeer noquery
+restrict 127.0.0.1
+restrict ::1
+{% for item in ntp_servers %}
+server {{ item }} iburst
+{% endfor %}
+includefile /etc/ntp/crypto/pw
+keys /etc/ntp/keys
@@ -0,0 +1,5 @@
+ntp_servers:
+ - 0.centos.pool.ntp.org
+ - 1.centos.pool.ntp.org
+ - 2.centos.pool.ntp.org