From a1c76e834ceee05cc1751b9c5596f93bd6e9f31b Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Wed, 11 Oct 2017 13:21:20 -0500 Subject: [PATCH] Simplify NTP checks/install This patch simplifies the checks and installation tasks for NTP. Debian and Red Hat had a check for NTP's presence but would then install NTP right afterwards anyways. In addition, there were tasks for atomic that weren't used anywhere else in the role. This patch also uses a dynamic include to reduce delays from skipped tasks. --- .../tasks/checks/check_ntp_atomic.yml | 10 ---------- .../tasks/checks/check_ntp_debian.yml | 15 --------------- .../tasks/checks/check_ntp_redhat.yml | 17 ----------------- roles/ceph-common/tasks/main.yml | 14 +++----------- roles/ceph-common/tasks/misc/ntp_atomic.yml | 13 ------------- roles/ceph-common/tasks/misc/ntp_debian.yml | 10 ++++------ roles/ceph-common/tasks/misc/ntp_redhat.yml | 10 ++++------ 7 files changed, 11 insertions(+), 78 deletions(-) delete mode 100644 roles/ceph-common/tasks/checks/check_ntp_atomic.yml delete mode 100644 roles/ceph-common/tasks/checks/check_ntp_debian.yml delete mode 100644 roles/ceph-common/tasks/checks/check_ntp_redhat.yml delete mode 100644 roles/ceph-common/tasks/misc/ntp_atomic.yml diff --git a/roles/ceph-common/tasks/checks/check_ntp_atomic.yml b/roles/ceph-common/tasks/checks/check_ntp_atomic.yml deleted file mode 100644 index 119c0ae38..000000000 --- a/roles/ceph-common/tasks/checks/check_ntp_atomic.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: check ntp installation on atomic - command: rpm -q chrony - args: - warn: no - register: ntp_pkg_query - ignore_errors: true - changed_when: false - tags: - - always diff --git a/roles/ceph-common/tasks/checks/check_ntp_debian.yml b/roles/ceph-common/tasks/checks/check_ntp_debian.yml deleted file mode 100644 index 1d537825b..000000000 --- a/roles/ceph-common/tasks/checks/check_ntp_debian.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- name: check ntp installation on debian - command: dpkg -s ntp - register: ntp_pkg_query - ignore_errors: true - changed_when: false - when: - - ansible_os_family == 'Debian' - tags: - - always - -- name: install ntp on debian - package: - name: ntp - state: present diff --git a/roles/ceph-common/tasks/checks/check_ntp_redhat.yml b/roles/ceph-common/tasks/checks/check_ntp_redhat.yml deleted file mode 100644 index 8327d25dc..000000000 --- a/roles/ceph-common/tasks/checks/check_ntp_redhat.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- name: check ntp installation on redhat - command: rpm -q ntp - args: - warn: no - register: ntp_pkg_query - ignore_errors: true - changed_when: false - when: - - ansible_os_family == 'RedHat' - tags: - - always - -- name: install ntp on redhat - package: - name: ntp - state: present diff --git a/roles/ceph-common/tasks/main.yml b/roles/ceph-common/tasks/main.yml index 535e13eb6..20fa452c0 100644 --- a/roles/ceph-common/tasks/main.yml +++ b/roles/ceph-common/tasks/main.yml @@ -46,18 +46,10 @@ # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent) static: False -- name: include misc/ntp_redhat.yml - include: misc/ntp_redhat.yml +- name: include ntp setup tasks + include: "misc/ntp_{{ ansible_os_family | lower }}.yml" when: - - ansible_os_family == 'RedHat' - - ntp_service_enabled - # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent) - static: False - -- name: include misc/ntp_debian.yml - include: misc/ntp_debian.yml - when: - - ansible_os_family == 'Debian' + - ansible_os_family in ['RedHat', 'Debian'] - ntp_service_enabled # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent) static: False diff --git a/roles/ceph-common/tasks/misc/ntp_atomic.yml b/roles/ceph-common/tasks/misc/ntp_atomic.yml deleted file mode 100644 index 4da8abe84..000000000 --- a/roles/ceph-common/tasks/misc/ntp_atomic.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- name: include ../checks/check_ntp_atomic.yml - include: ../checks/check_ntp_atomic.yml - when: - - is_atomic - -- name: start the ntp service - service: - name: chronyd - enabled: yes - state: started - when: - - ntp_pkg_query.rc == 0 diff --git a/roles/ceph-common/tasks/misc/ntp_debian.yml b/roles/ceph-common/tasks/misc/ntp_debian.yml index 7eab2e410..f94003d7a 100644 --- a/roles/ceph-common/tasks/misc/ntp_debian.yml +++ b/roles/ceph-common/tasks/misc/ntp_debian.yml @@ -1,13 +1,11 @@ --- -- name: include ../checks/check_ntp_debian.yml - include: ../checks/check_ntp_debian.yml - when: - - ansible_os_family == 'Debian' +- name: install ntp on debian + package: + name: ntp + state: present - name: start the ntp service service: name: ntp enabled: yes state: started - when: - - ntp_pkg_query.rc == 0 diff --git a/roles/ceph-common/tasks/misc/ntp_redhat.yml b/roles/ceph-common/tasks/misc/ntp_redhat.yml index 332841b9c..7e3481508 100644 --- a/roles/ceph-common/tasks/misc/ntp_redhat.yml +++ b/roles/ceph-common/tasks/misc/ntp_redhat.yml @@ -1,13 +1,11 @@ --- -- name: include ../checks/check_ntp_redhat.yml - include: ../checks/check_ntp_redhat.yml - when: - - ansible_os_family == 'RedHat' +- name: install ntp on redhat + package: + name: ntp + state: present - name: start the ntp service service: name: ntpd enabled: yes state: started - when: - - ntp_pkg_query.rc == 0