From 03d904b7ea2a7326767a9f30e4c016c28f0ce61a Mon Sep 17 00:00:00 2001 From: Thomas Woerner <twoerner@redhat.com> Date: Fri, 5 Jul 2019 17:47:41 +0200 Subject: [PATCH] ipaclient: Support sync_time changes of 4.8.0 sync_time is not using options anymore, but has two new arguments. These are ntp_servers and ntp_pool. The options argument is not used anymore. This requires to use inspect on sync_time to be able to detect if the old or the new function is available. The call for get_time_source has been added, but is documented out as the call is only useful in interactive mode. ipaclient_test now returns ntp_servers and ntp_pool, which are then used for ipaclient_setup_ntp. --- .../ipaclient/library/ipaclient_setup_ntp.py | 7 +++++- roles/ipaclient/library/ipaclient_test.py | 24 ++++++++++++++++--- roles/ipaclient/tasks/install.yml | 4 ++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/roles/ipaclient/library/ipaclient_setup_ntp.py b/roles/ipaclient/library/ipaclient_setup_ntp.py index 6fb6b18e..382f6b31 100644 --- a/roles/ipaclient/library/ipaclient_setup_ntp.py +++ b/roles/ipaclient/library/ipaclient_setup_ntp.py @@ -124,7 +124,12 @@ def main(): if sync_time is not None: if options.conf_ntp: # Attempt to configure and sync time with NTP server (chrony). - synced_ntp = sync_time(options, fstore, statestore) + argspec = inspect.getargspec(sync_time) + if "options" not in argspec.args: + synced_ntp = sync_time(options.ntp_servers, options.ntp_pool, + fstore, statestore) + else: + synced_ntp = sync_time(options, fstore, statestore) elif options.on_master: # If we're on master skipping the time sync here because it was done # in ipa-server-install diff --git a/roles/ipaclient/library/ipaclient_test.py b/roles/ipaclient/library/ipaclient_test.py index 3d6f4b65..f12bb563 100644 --- a/roles/ipaclient/library/ipaclient_test.py +++ b/roles/ipaclient/library/ipaclient_test.py @@ -492,9 +492,10 @@ def main(): try: timeconf.check_timedate_services() except timeconf.NTPConflictingService as e: - logger.info("WARNING: conflicting time&date synchronization service '{}'" - " will be disabled".format(e.conflicting_service)) - logger.info("in favor of chronyd") + logger.info( + "WARNING: conflicting time&date synchronization service " + "'%s' will be disabled in favor of chronyd" % \ + e.conflicting_service) logger.info("") except timeconf.NTPConfigurationError: pass @@ -800,6 +801,13 @@ def main(): # "Proceed with fixed values and no DNS discovery?", False): # raise ScriptError(rval=CLIENT_INSTALL_ERROR) + # Do not ask for time source + #if options.conf_ntp: + # if not options.on_master and not options.unattended and not ( + # options.ntp_servers or options.ntp_pool): + # options.ntp_servers, options.ntp_pool = \ + # timeconf.get_time_source() + cli_realm = ds.realm cli_realm_source = ds.realm_source logger.debug("will use discovered realm: %s", cli_realm) @@ -829,6 +837,14 @@ def main(): logger.info("BaseDN: %s", cli_basedn) logger.debug("BaseDN source: %s", cli_basedn_source) + if not options.on_master: + if options.ntp_servers: + for server in options.ntp_servers: + logger.info("NTP server: %s", server) + + if options.ntp_pool: + logger.info("NTP pool: %s", options.ntp_pool) + # ipa-join would fail with IP address instead of a FQDN for srv in cli_server: try: @@ -894,6 +910,8 @@ def main(): client_domain=client_domain, dnsok=dnsok, sssd=options.sssd, + ntp_servers=options.ntp_servers, + ntp_pool=options.ntp_pool, client_already_configured=client_already_configured, ipa_python_version=IPA_PYTHON_VERSION) diff --git a/roles/ipaclient/tasks/install.yml b/roles/ipaclient/tasks/install.yml index 906a6925..e66c46e1 100644 --- a/roles/ipaclient/tasks/install.yml +++ b/roles/ipaclient/tasks/install.yml @@ -63,8 +63,8 @@ - name: Install - Configure NTP ipaclient_setup_ntp: ### basic ### - ntp_servers: "{{ ipaclient_ntp_servers | default(omit) }}" - ntp_pool: "{{ ipaclient_ntp_pool | default(omit) }}" + ntp_servers: "{{ result_ipaclient_test.ntp_servers | default(omit) }}" + ntp_pool: "{{ result_ipaclient_test.ntp_pool | default(omit) }}" no_ntp: "{{ ipaclient_no_ntp }}" # force_ntpd: "{{ ipaclient_force_ntpd }}" on_master: "{{ ipaclient_on_master }}" -- GitLab