SHA256
1
0
forked from pool/cloud-init

- Add cloud-init-ntp-conf-suse.patch

+ ntp configuration was broken on sles and opensuse lp#1726572

OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=93
This commit is contained in:
Robert Schweikert 2017-11-11 12:33:43 +00:00 committed by Git OBS Bridge
parent 6927c014db
commit e03ed2d736
3 changed files with 176 additions and 2 deletions

View File

@ -0,0 +1,166 @@
--- cloudinit/config/cc_ntp.py.orig
+++ cloudinit/config/cc_ntp.py
@@ -23,7 +23,7 @@ frequency = PER_INSTANCE
NTP_CONF = '/etc/ntp.conf'
TIMESYNCD_CONF = '/etc/systemd/timesyncd.conf.d/cloud-init.conf'
NR_POOL_SERVERS = 4
-distros = ['centos', 'debian', 'fedora', 'opensuse', 'ubuntu']
+distros = ['centos', 'debian', 'fedora', 'opensuse', 'sles', 'ubuntu']
# The schema definition for each cloud-config module is a strict contract for
@@ -172,6 +172,9 @@ def rename_ntp_conf(config=None):
def generate_server_names(distro):
names = []
+ pool_distro = distro
+ if distro == 'sles':
+ pool_distro = 'opensuse'
for x in range(0, NR_POOL_SERVERS):
name = "%d.%s.pool.ntp.org" % (x, distro)
names.append(name)
--- /dev/null
+++ templates/ntp.conf.opensuse.tmpl
@@ -0,0 +1,88 @@
+## template:jinja
+
+##
+## Radio and modem clocks by convention have addresses in the
+## form 127.127.t.u, where t is the clock type and u is a unit
+## number in the range 0-3.
+##
+## Most of these clocks require support in the form of a
+## serial port or special bus peripheral. The particular
+## device is normally specified by adding a soft link
+## /dev/device-u to the particular hardware device involved,
+## where u correspond to the unit number above.
+##
+## Generic DCF77 clock on serial port (Conrad DCF77)
+## Address: 127.127.8.u
+## Serial Port: /dev/refclock-u
+##
+## (create soft link /dev/refclock-0 to the particular ttyS?)
+##
+# server 127.127.8.0 mode 5 prefer
+
+##
+## Undisciplined Local Clock. This is a fake driver intended for backup
+## and when no outside source of synchronized time is available.
+##
+# server 127.127.1.0 # local clock (LCL)
+# fudge 127.127.1.0 stratum 10 # LCL is unsynchronized
+
+##
+## Add external Servers using
+## # rcntpd addserver <yourserver>
+## The servers will only be added to the currently running instance, not
+## to /etc/ntp.conf.
+##
+{% if pools %}# pools
+{% endif %}
+{% for pool in pools -%}
+pool {{pool}} iburst
+{% endfor %}
+{%- if servers %}# servers
+{% endif %}
+{% for server in servers -%}
+server {{server}} iburst
+{% endfor %}
+
+# Access control configuration; see /usr/share/doc/packages/ntp/html/accopt.html for
+# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
+# might also be helpful.
+#
+# Note that "restrict" applies to both servers and clients, so a configuration
+# that might be intended to block requests from certain clients could also end
+# up blocking replies from your own upstream servers.
+
+# By default, exchange time with everybody, but don't allow configuration.
+restrict -4 default notrap nomodify nopeer noquery
+restrict -6 default notrap nomodify nopeer noquery
+
+# Local users may interrogate the ntp server more closely.
+restrict 127.0.0.1
+restrict ::1
+
+# Clients from this (example!) subnet have unlimited access, but only if
+# cryptographically authenticated.
+#restrict 192.168.123.0 mask 255.255.255.0 notrust
+
+##
+## Miscellaneous stuff
+##
+
+driftfile /var/lib/ntp/drift/ntp.drift # path for drift file
+
+logfile /var/log/ntp # alternate log file
+# logconfig =syncstatus + sysevents
+# logconfig =all
+
+# statsdir /tmp/ # directory for statistics files
+# filegen peerstats file peerstats type day enable
+# filegen loopstats file loopstats type day enable
+# filegen clockstats file clockstats type day enable
+
+#
+# Authentication stuff
+#
+keys /etc/ntp.keys # path for keys file
+trustedkey 1 # define trusted keys
+requestkey 1 # key (7) for accessing server variables
+controlkey 1 # key (6) for accessing server variables
+
--- templates/ntp.conf.sles.tmpl.orig
+++ templates/ntp.conf.sles.tmpl
@@ -1,17 +1,5 @@
## template:jinja
-################################################################################
-## /etc/ntp.conf
-##
-## Sample NTP configuration file.
-## See package 'ntp-doc' for documentation, Mini-HOWTO and FAQ.
-## Copyright (c) 1998 S.u.S.E. GmbH Fuerth, Germany.
-##
-## Author: Michael Andres, <ma@suse.de>
-## Michael Skibbe, <mskibbe@suse.de>
-##
-################################################################################
-
##
## Radio and modem clocks by convention have addresses in the
## form 127.127.t.u, where t is the clock type and u is a unit
--- tests/unittests/test_handler/test_handler_ntp.py.orig
+++ tests/unittests/test_handler/test_handler_ntp.py
@@ -429,5 +429,31 @@ class TestNtp(FilesystemMockingTestCase)
"[Time]\nNTP=192.168.2.1 192.168.2.2 0.mypool.org \n",
content.decode())
+ def test_write_ntp_config_template_defaults_pools_empty_lists_sles(self):
+ """write_ntp_config_template defaults pools servers upon empty config.
+
+ When both pools and servers are empty, default NR_POOL_SERVERS get
+ configured.
+ """
+ distro = 'sles'
+ mycloud = self._get_cloud(distro)
+ ntp_conf = self.tmp_path('ntp.conf', self.new_root) # Doesn't exist
+ # Create ntp.conf.tmpl
+ with open('{0}.tmpl'.format(ntp_conf), 'wb') as stream:
+ stream.write(NTP_TEMPLATE)
+ with mock.patch('cloudinit.config.cc_ntp.NTP_CONF', ntp_conf):
+ cc_ntp.write_ntp_config_template({}, mycloud, ntp_conf)
+ content = util.read_file_or_url('file://' + ntp_conf).contents
+ default_pools = [
+ "{0}.{1}.pool.ntp.org".format(x, 'opensuse')
+ for x in range(0, cc_ntp.NR_POOL_SERVERS)]
+ self.assertEqual(
+ "servers []\npools {0}\n".format(default_pools),
+ content.decode())
+ self.assertIn(
+ "Adding distro default ntp pool servers: {0}".format(
+ ",".join(default_pools)),
+ self.logs.getvalue())
+
# vi: ts=4 expandtab

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Sat Nov 11 12:32:54 UTC 2017 - rjschwei@suse.com
- Add cloud-init-ntp-conf-suse.patch
+ ntp configuration was broken on sles and opensuse lp#1726572
-------------------------------------------------------------------
Wed Nov 8 21:26:15 UTC 2017 - rjschwei@suse.com

View File

@ -29,11 +29,13 @@ Source1: rsyslog-cloud-init.cfg
# Remove Patch 4 & 5 for next source updated, included upstream
Patch4: zypp_add_repos.diff
Patch5: zypp_add_repo_test.patch
# FIXME cloud-init-hosts-template.patch proposed for upstream merge (bsc#1064594)
# Remove Patch 6 for next source updated, included upstream (bsc#1064594)
Patch6: cloud-init-hosts-template.patch
# FIXME cloud-init-ntp-conf-suse.patch proposed for upstream merge (lp#1726572)
Patch7: cloud-init-ntp-conf-suse.patch
Patch10: cloud-init-no-user-lock-if-already-locked.patch
Patch12: fix-default-systemd-unit-dir.patch
# FIXME cloud-init-more-tasks.patch proposed for upstream merge
# Remove Patch 13 for next source updated, included upstream
Patch13: cloud-init-more-tasks.patch
# python2 disables SIGPIPE, causing broken pipe errors in shell scripts (bsc#903449)
Patch20: cloud-init-python2-sigpipe.patch