From 1943fb5f091e400464e458485135c2c6e8bf54e8 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 1 Oct 2022 21:41:52 +0900 Subject: [PATCH] Change logic to deploy `/etc/systemd/timesyncd.conf`. --- cookbooks/base/default.rb | 13 ++++++++++++ .../files/etc/systemd/timesyncd.2204.conf | 20 +++++++++++++++++++ cookbooks/consul/dnsmasq.rb | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 cookbooks/base/files/etc/systemd/timesyncd.2204.conf diff --git a/cookbooks/base/default.rb b/cookbooks/base/default.rb index 86feaa9..c2824b7 100644 --- a/cookbooks/base/default.rb +++ b/cookbooks/base/default.rb @@ -86,12 +86,25 @@ when "20.04", "22.04" service 'systemd-timesyncd' do action :enable end +end +case node['platform_version'] +when "20.04" remote_file '/etc/systemd/timesyncd.conf' do owner 'root' group 'root' mode '0644' + notifies :restart, 'service[systemd-timesyncd]' + end +when "22.04" + remote_file '/etc/systemd/timesyncd.conf' do + owner 'root' + group 'root' + mode '0644' + + source 'files/etc/systemd/timesyncd.2204.conf' + notifies :restart, 'service[systemd-timesyncd]' end end diff --git a/cookbooks/base/files/etc/systemd/timesyncd.2204.conf b/cookbooks/base/files/etc/systemd/timesyncd.2204.conf new file mode 100644 index 0000000..0357e4c --- /dev/null +++ b/cookbooks/base/files/etc/systemd/timesyncd.2204.conf @@ -0,0 +1,20 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; either version 2.1 of the License, or (at your option) +# any later version. +# +# Entries in this file show the compile time defaults. Local configuration +# should be created by either modifying this file, or by creating "drop-ins" in +# the timesyncd.conf.d/ subdirectory. The latter is generally recommended. +# Defaults can be restored by simply deleting this file and all drop-ins. +# +# See timesyncd.conf(5) for details. + +[Time] +NTP=192.168.10.1 +#FallbackNTP=ntp.ubuntu.com +#RootDistanceMaxSec=5 +#PollIntervalMinSec=32 +#PollIntervalMaxSec=2048 diff --git a/cookbooks/consul/dnsmasq.rb b/cookbooks/consul/dnsmasq.rb index d9f9e20..a048bb2 100644 --- a/cookbooks/consul/dnsmasq.rb +++ b/cookbooks/consul/dnsmasq.rb @@ -13,7 +13,7 @@ when "22.04" group 'root' mode '644' - source 'templates/etc/systemd/resolved.conf.2022.erb' + source 'templates/etc/systemd/resolved.conf.2204.erb' variables(dns: node['consul']['dns']) notifies :restart, 'service[systemd-resolved]', :immediately