Explorar o código

ntpd deployment

Signed-off-by: Abdelaziz Raji <abdelaziz.raji@gmail.com>
Abdelaziz Raji %!s(int64=4) %!d(string=hai) anos
pai
achega
f28cd0dc4a

+ 2 - 0
slurm/roles/ntp/README.md

@@ -0,0 +1,2 @@
+ntp deployment using ntpd and configuration basic template.
+handler will restart and wait for at least one server to sync .

+ 14 - 0
slurm/roles/ntp/handlers/main.yml

@@ -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
+ 
+
+
+

+ 19 - 0
slurm/roles/ntp/tasks/main.yml

@@ -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

+ 16 - 0
slurm/roles/ntp/templates/ntp.conf.j2

@@ -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
+
+

+ 5 - 0
slurm/roles/ntp/vars/main.yml

@@ -0,0 +1,5 @@
+ntp_servers: 
+  - 0.centos.pool.ntp.org
+  - 1.centos.pool.ntp.org
+  - 2.centos.pool.ntp.org
+