]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-common: merge ntp_debian.yml and ntp_rpm.yml
authorRishabh Dave <ridave@redhat.com>
Wed, 12 Dec 2018 11:15:00 +0000 (16:45 +0530)
committerSébastien Han <seb@redhat.com>
Mon, 14 Jan 2019 15:37:35 +0000 (16:37 +0100)
Merge ntp_debian.yml and ntp_rpm.yml into one (the new file is called
setup_ntp.yml) since they are almost identical.

Since this is as a "as it is" backport for the original commit, it also
adds the feature of supporting multiple NTP daemons (namely, chronyd &
timesyncd). This is to maintain consistency across all branches
since the backport for stable-3.2 was auto-merged by mergify despite
of conflicts.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit b03ab607422eda0094d74223d52024a373b7ee9a)

roles/ceph-common/tasks/main.yml
roles/ceph-common/tasks/misc/ntp_debian.yml [deleted file]
roles/ceph-common/tasks/misc/ntp_rpm.yml [deleted file]
roles/ceph-common/tasks/misc/setup_ntp.yml [new file with mode: 0644]

index f49b1903a54c86e1123fd1ef2581a0ddbb31c09a..a44b9cd1c9611172eb81a114a24a1b65aa48df12 100644 (file)
   # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent)
   static: False
 
-- name: include ntp debian setup tasks
-  include: "misc/ntp_debian.yml"
-  when:
-    - ansible_os_family == 'Debian'
-    - ntp_service_enabled
+- name: include ntp setup tasks
+  include: misc/setup_ntp.yml
+  when: ntp_service_enabled
+  tags: configure_ntp
   # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent)
   static: False
 
-- name: include ntp rpm setup tasks
-  include: "misc/ntp_rpm.yml"
-  when:
-    - ansible_os_family in ['RedHat', 'Suse']
-    - ntp_service_enabled
-  # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent)
-  static: False
 
 - name: get ceph version
   command: ceph --version
diff --git a/roles/ceph-common/tasks/misc/ntp_debian.yml b/roles/ceph-common/tasks/misc/ntp_debian.yml
deleted file mode 100644 (file)
index f1da045..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
----
-- name: setup ntpd
-  block:
-    - command: timedatectl set-ntp no
-    - package:
-        name: ntp
-        state: present
-    - service:
-        name: ntp
-        enabled: yes
-        state: started
-  when: ntp_daemon_type == "ntpd"
-
-- name: setup chrony
-  block:
-    - command: timedatectl set-ntp no
-    - package:
-        name: chrony
-        state: present
-    - service:
-        name: chronyd
-        enabled: yes
-        state: started
-  when: ntp_daemon_type == "chronyd"
-
-- name: setup timesyncd
-  block:
-    - command: timedatectl set-ntp on
-  when: ntp_daemon_type == "timesyncd"
diff --git a/roles/ceph-common/tasks/misc/ntp_rpm.yml b/roles/ceph-common/tasks/misc/ntp_rpm.yml
deleted file mode 100644 (file)
index 866667c..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
----
-- name: setup ntpd
-  block:
-    - command: timedatectl set-ntp no
-    - package:
-        name: ntp
-        state: present
-    - service:
-        name: ntpd
-        enabled: yes
-        state: started
-  when: ntp_daemon_type == "ntpd"
-
-- name: setup chrony
-  block:
-    - command: timedatectl set-ntp no
-    - package:
-        name: chrony
-        state: present
-    - service:
-        name: chronyd
-        enabled: yes
-        state: started
-  when: ntp_daemon_type == "chronyd"
-
-- name: setup timesyncd
-  block:
-    - command: timedatectl set-ntp on
-  when: ntp_daemon_type == "timesyncd"
diff --git a/roles/ceph-common/tasks/misc/setup_ntp.yml b/roles/ceph-common/tasks/misc/setup_ntp.yml
new file mode 100644 (file)
index 0000000..b6a2ce3
--- /dev/null
@@ -0,0 +1,51 @@
+---
+- name: set ntp service name depending on OS family
+  block:
+    - name: set ntp service name for Debian family
+      set_fact:
+        ntp_service_name: ntp
+      when: ansible_os_family == 'Debian'
+    - name: set ntp service name for Red Hat family
+      set_fact:
+        ntp_service_name: ntpd
+      when: ansible_os_family in ['RedHat', 'Suse']
+
+- name: setup ntp daemon
+  block:
+    - name: install and enable timesyncd
+      command: timedatectl set-ntp on
+      when: ntp_daemon_type == "timesyncd"
+
+    - name: disable time sync using timesyncd if we are not using it
+      command: timedatectl set-ntp no
+      when: ntp_daemon_type != "timesyncd"
+
+    - name: setup ntpd
+      when: ntp_daemon_type == "ntpd"
+      block:
+        - name: install ntp
+          package:
+            name: ntp
+            state: present
+          register: result
+          until: result is succeeded
+        - name: enable and start ntp
+          service:
+            name: "{{ ntp_service_name }}"
+            enabled: yes
+            state: started
+
+    - name: setup chronyd
+      when: ntp_daemon_type == "chronyd"
+      block:
+        - name: install chrony
+          package:
+            name: chrony
+            state: present
+          register: result
+          until: result is succeeded
+        - name: enable and start chronyd
+          service:
+            name: chronyd
+            enabled: yes
+            state: started