Browse Source

Merge pull request #143 from araji/feat/ntp

Feature #142 ,time sync all nodes
Lucas A. Wilson 4 years ago
parent
commit
f3c515b1ef

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

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

+ 26 - 0
slurm/roles/common/handlers/main.yml

@@ -0,0 +1,26 @@
+---
+- name: restart ntpd
+  service: 
+    name=ntpd
+    state=restarted
+    enabled=yes
+
+- name: restart chrony
+  service: 
+    name=chronyd 
+    state=restarted 
+    enabled=yes
+
+- name: sync ntp clocks
+  command: ntpdc -np
+  register: ntp_clock
+  until:  ntp_clock.stdout.find('*') > -1
+  retries: 10
+  delay: 60
+
+- name: sync chrony sources
+  command: chronyc sources
+  register: chrony_src
+  until:  chrony_src.stdout.find('^*') > -1
+  retries: 6
+  delay: 10

+ 2 - 0
slurm/roles/common/tasks/main.yml

@@ -0,0 +1,2 @@
+- name: deploy time ntp/chrony
+  include_tasks: ntp.yml

+ 42 - 0
slurm/roles/common/tasks/ntp.yml

@@ -0,0 +1,42 @@
+---
+  
+  - name: deploy ntp servers
+    block:
+      - name: deploy ntpd
+        package:
+          name: ntp
+          state: present
+      - name: deploy ntpdate
+        package:
+          name: ntpdate
+          state: present
+      - 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 ntp clocks
+    when:  ( ansible_distribution == "CentOS" or   ansible_distribution == "RedHat" ) and ansible_distribution_major_version | int < 8
+  - name:   deploy chrony server
+    block:
+      - name: deploy chrony
+        package:
+            name: chrony
+            state: present
+      - name: update ntp servers
+        template:
+          src: chrony.conf.j2
+          dest: /etc/chrony.conf
+          owner: root
+          group: root
+          mode: u=rw,g=r,o=r
+          backup: yes
+        notify:
+          - restart chrony
+          - sync chrony sources
+    when:  ( ansible_distribution == "CentOS" or   ansible_distribution == "RedHat" ) and ansible_distribution_major_version | int > 7

+ 42 - 0
slurm/roles/common/templates/chrony.conf.j2

@@ -0,0 +1,42 @@
+# Use public servers from the pool.ntp.org project.
+# Please consider joining the pool (http://www.pool.ntp.org/join.html).
+{% for item in chrony_servers %}
+pool {{ item }} iburst
+{% endfor %}
+
+
+# Record the rate at which the system clock gains/losses time.
+driftfile /var/lib/chrony/drift
+
+# Allow the system clock to be stepped in the first three updates
+# if its offset is larger than 1 second.
+makestep 1.0 3
+
+# Enable kernel synchronization of the real-time clock (RTC).
+rtcsync
+
+# Enable hardware timestamping on all interfaces that support it.
+#hwtimestamp *
+
+# Increase the minimum number of selectable sources required to adjust
+# the system clock.
+#minsources 2
+
+# Allow NTP client access from local network.
+#allow 192.168.0.0/16
+
+# Serve time even if not synchronized to a time source.
+#local stratum 10
+
+# Specify file containing keys for NTP authentication.
+keyfile /etc/chrony.keys
+
+# Get TAI-UTC offset and leap seconds from the system tz database.
+leapsectz right/UTC
+
+# Specify directory for log files.
+logdir /var/log/chrony
+
+# Select which information is logged.
+#log measurements statistics tracking
+

+ 16 - 0
slurm/roles/common/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
+
+

+ 6 - 0
slurm/roles/common/vars/main.yml

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

+ 6 - 1
slurm/roles/slurm-manager/tasks/main.yml

@@ -13,12 +13,17 @@
 #  limitations under the License.
 
 ---
-
+- name: create download folder
+  file:
+    path: /root/Downloads
+    state: directory
+    mode: '0755'
 - name: Download Slurm source
   get_url:
     url: "{{ slurm_url }}"
     dest: /root/Downloads/
     checksum: "{{ slurm_md5 }}"
+    validate_certs: no    
   tags: install
 
 - name: Build SLURM RPMs

+ 1 - 0
slurm/slurm.yml

@@ -21,6 +21,7 @@
 - hosts: cluster
   gather_facts: false
   roles:
+    - common
     - slurm-common
 
 # Apply Manager Config, start services