From 35e50bb6b8f149d9edac6718121407b08ff402d8 Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Thu, 5 Mar 2020 16:46:05 +0000
Subject: [PATCH] Skip resmo.ntp role if ntp_service_enabled is false

We enable ntpd by default, and provide a variable to disable it -
ntp_service_enabled. It is also automatically disabled if the user
enables the chrony container (kolla_enable_chrony).

However, setting ntp_service_enabled to false will cause the host
configure commands to fail due to a bug in the resmo.ntp role. This is
because it tries to configure the ntpd service in systemd, but it will
not exist so the task fails.

This change fixes the issue by skipping the resmo.ntp role if the NTP
service is disabled.

Change-Id: I640873c11ceae5008030dc03984c089a410a0cee
Story: 2007384
Task: 38968
---
 ansible/ntp.yml                                            | 5 +++++
 .../notes/skip-ntp-if-disabled-585c756f01b34bfa.yaml       | 7 +++++++
 2 files changed, 12 insertions(+)
 create mode 100644 releasenotes/notes/skip-ntp-if-disabled-585c756f01b34bfa.yaml

diff --git a/ansible/ntp.yml b/ansible/ntp.yml
index 9160d990..df2a455f 100644
--- a/ansible/ntp.yml
+++ b/ansible/ntp.yml
@@ -8,3 +8,8 @@
       become: True
     - role: resmo.ntp
       become: True
+      # NOTE(mgoddard): The resmo.ntp role fails if ntp_service_enabled is set
+      # to false, since it tries to disable the ntpd service which does not
+      # exist. Skip the role if it is disabled.
+      # https://storyboard.openstack.org/#!/story/2007384.
+      when: ntp_service_enabled | bool
diff --git a/releasenotes/notes/skip-ntp-if-disabled-585c756f01b34bfa.yaml b/releasenotes/notes/skip-ntp-if-disabled-585c756f01b34bfa.yaml
new file mode 100644
index 00000000..dd474122
--- /dev/null
+++ b/releasenotes/notes/skip-ntp-if-disabled-585c756f01b34bfa.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    Fixes an issue where host configuration would fail if
+    ``ntp_service_enabled`` is set to ``false`` or ``kolla_enable_chrony`` is
+    set to ``true``. See `story 2007384
+    <https://storyboard.openstack.org/#!/story/2007384>`__ for details.
-- 
GitLab