kdevops.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: kdevops@lists.linux.dev
Subject: [PATCH RFC] devconfig: Copy timezone setting to target nodes
Date: Mon, 18 Mar 2024 10:24:26 -0400	[thread overview]
Message-ID: <171077108366.707717.4358880365547643234.stgit@renoir.1015granger.net> (raw)

From: Chuck Lever <chuck.lever@oracle.com>

We want the time and timezone settings on target nodes to match the
hypervisor / control host settings so that things like journald,
watchdogs, and NFS/Kerberos work correctly.

Instead of changing the hypervisor's timezone setting, which is
somewhat surprising behavior, add a Kconfig option to simply set
each target node's timezone to be the same as the control host's.

Note: the systemd-timesyncd infrastructure assumes a modern version
of the timedatectl command is available on the control host and
target nodes. It might not be available on older Linux releases.

Since DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD_TIMEZONE results in
surprising behavior, its default setting is changed to N.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 kconfigs/Kconfig.ansible_provisioning       |   12 +++++++++++-
 playbooks/roles/devconfig/defaults/main.yml |    1 +
 playbooks/roles/devconfig/tasks/main.yml    |   18 ++++++++++++++++++
 scripts/systemd-timesync.Makefile           |    4 ++++
 4 files changed, 34 insertions(+), 1 deletion(-)

In addition to this change, we might consider:

a. removing DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD_TIMEZONE
b. splitting the _NTP options into separate options for the control
   host, which is likely to have NTP configured already, and target
   nodes, which are unlikely to have NTP on bringup
c. providing a _CUSTOM setting for NTP servers, since clouds and
   other providers likely have their own stratum 3 time servers that
   they prefer
d. making the control host a local NTP server and have the target
   nodes use that

Comments, thoughts, opinions?


diff --git a/kconfigs/Kconfig.ansible_provisioning b/kconfigs/Kconfig.ansible_provisioning
index 391331a7617b..e2abd69855cd 100644
--- a/kconfigs/Kconfig.ansible_provisioning
+++ b/kconfigs/Kconfig.ansible_provisioning
@@ -218,9 +218,19 @@ config DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD
 
 if DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD
 
+config DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD_COPY_HOST_TIMEZONE
+	bool "Copy control host's timezone to target nodes on bringup"
+	default y
+	help
+	  When set to Y, kdevops copies the control host's timezone setting
+	  to each target node. When set to N, target nodes use the default
+	  timezone set by the Linux distribution (typically, UTC).
+
+	  The default is to copy the control host's timezone.
+
 config DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD_TIMEZONE
 	bool "Enable changing timezone using systemd-timesyncd"
-	default y
+	default n
 	help
           Set the timezone with timedatectl. Without this then we'd leave all
 	  nodes with whatever time zone they were installed with. The value in
diff --git a/playbooks/roles/devconfig/defaults/main.yml b/playbooks/roles/devconfig/defaults/main.yml
index 92552dfd87a7..b0a6536603e8 100644
--- a/playbooks/roles/devconfig/defaults/main.yml
+++ b/playbooks/roles/devconfig/defaults/main.yml
@@ -50,6 +50,7 @@ devconfig_systemd_journal_remote_url: "http://192.168.124.1"
 devconfig_systemd_journal_remote_path: "/var/log/journal/remote/"
 
 devconfig_enable_systemd_timesyncd: False
+devconfig_enable_systemd_timesyncd_copy_host_timezone: False
 devconfig_enable_systemd_timesyncd_ntp: False
 devconfig_enable_systemd_timesyncd_ntp_google: False
 devconfig_enable_systemd_timesyncd_ntp_debian: False
diff --git a/playbooks/roles/devconfig/tasks/main.yml b/playbooks/roles/devconfig/tasks/main.yml
index 1e67f91e44c2..ab2dbeea3716 100644
--- a/playbooks/roles/devconfig/tasks/main.yml
+++ b/playbooks/roles/devconfig/tasks/main.yml
@@ -518,6 +518,24 @@
   when:
     - devconfig_enable_systemd_timesyncd|bool
 
+- name: Get the host's timezone
+  ansible.builtin.command: "timedatectl show -p Timezone --value"
+  register: host_timezone
+  delegate_to: localhost
+  run_once: true
+  when:
+    - devconfig_enable_systemd_timesyncd_copy_host_timezone|bool
+    - not devconfig_enable_systemd_timesyncd_timezone|bool
+
+- name: Set the timezone on the target nodes to {{ host_timezone.stdout }}
+  become: yes
+  become_flags: 'su - -c'
+  become_method: sudo
+  ansible.builtin.command: "timedatectl set-timezone {{ host_timezone.stdout }}"
+  when:
+    - devconfig_enable_systemd_timesyncd_copy_host_timezone|bool
+    - not devconfig_enable_systemd_timesyncd_timezone|bool
+
 - name: Set timezone on the client to {{ devconfig_systemd_timesyncd_timezone }}
   become: yes
   become_flags: 'su - -c'
diff --git a/scripts/systemd-timesync.Makefile b/scripts/systemd-timesync.Makefile
index d9ddf375711f..59f58f859f02 100644
--- a/scripts/systemd-timesync.Makefile
+++ b/scripts/systemd-timesync.Makefile
@@ -3,6 +3,10 @@
 ifeq (y,$(CONFIG_DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD))
 ANSIBLE_EXTRA_ARGS += devconfig_enable_systemd_timesyncd='True'
 
+ifeq (y,$(CONFIG_DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD_COPY_HOST_TIMEZONE))
+ANSIBLE_EXTRA_ARGS += devconfig_enable_systemd_timesyncd_copy_host_timezone='True'
+endif
+
 ifeq (y,$(CONFIG_DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD_TIMEZONE))
 ANSIBLE_EXTRA_ARGS += devconfig_enable_systemd_timesyncd_timezone='True'
 ANSIBLE_EXTRA_ARGS_DIRECT += devconfig_systemd_timesyncd_timezone='$(subst ",,$(CONFIG_DEVCONFIG_SYSTEMD_TIMESYNCD_TIMEZONE))'



             reply	other threads:[~2024-03-18 14:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 14:24 Chuck Lever [this message]
2024-03-18 17:17 ` [PATCH RFC] devconfig: Copy timezone setting to target nodes Luis Chamberlain
2024-03-19 15:27   ` Chuck Lever III
2024-03-19 18:32     ` Luis Chamberlain
2024-03-19 20:32       ` Chuck Lever III
2024-03-19 20:49         ` Luis Chamberlain
2024-03-19 21:01           ` Chuck Lever III
2024-03-19 22:31             ` Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=171077108366.707717.4358880365547643234.stgit@renoir.1015granger.net \
    --to=cel@kernel.org \
    --cc=kdevops@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).