Преглед на файлове

move ntp to slurm/roles/common as a temporary location
add rhel 8 and chrony support

Signed-off-by: Abdelaziz Raji <abdelaziz.raji@gmail.com>

Abdelaziz Raji преди 4 години
родител
ревизия
982bbb4244

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

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

@@ -0,0 +1,20 @@
+---
+- 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

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

@@ -0,0 +1,4 @@
+- name: enable required repos
+  include_tasks: base.yml
+- 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
+

slurm/roles/ntp/templates/ntp.conf.j2 → slurm/roles/common/templates/ntp.conf.j2


+ 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 

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

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

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

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

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

@@ -1,23 +0,0 @@
----
-- 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 - 4
slurm/roles/ntp/vars/main.yml

@@ -1,4 +0,0 @@
-ntp_servers: 
-  - 0.centos.pool.ntp.org
-  - 1.centos.pool.ntp.org
-  - 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