From 35614d7a889d2a3cd93e60425417c3ede0d81e2b Mon Sep 17 00:00:00 2001 From: Thomas Woerner Date: Mon, 25 Mar 2024 11:06:01 +0100 Subject: [PATCH] ipalib.install.kinit moved to ipalib FreeIPA PR https://github.com/freeipa/freeipa/pull/7286 moved ipalib.install.kinit to ipalib. It is first tried to import kinit_keytab and kinit_password from ipalib.kinit, then ipalib.install.kinit and finally in some cases where support for IPA 4.5.0 is needed still also ipapython.ipautil. Related: https://github.com/freeipa/freeipa/pull/7286 --- plugins/module_utils/ansible_freeipa_module.py | 8 ++++++-- roles/ipaclient/library/ipaclient_get_otp.py | 8 ++++++-- roles/ipaclient/module_utils/ansible_ipa_client.py | 8 ++++++-- roles/ipareplica/module_utils/ansible_ipa_replica.py | 5 ++++- roles/ipaserver/library/ipaserver_get_connected_server.py | 8 ++++++-- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py index d64c9e31b5..51c02c739a 100644 --- a/plugins/module_utils/ansible_freeipa_module.py +++ b/plugins/module_utils/ansible_freeipa_module.py @@ -87,9 +87,13 @@ def getargspec(func): from ipalib.constants import DEFAULT_CONFIG, LDAP_GENERALIZED_TIME_FORMAT try: - from ipalib.install.kinit import kinit_password, kinit_keytab + from ipalib.kinit import kinit_password, kinit_keytab except ImportError: - from ipapython.ipautil import kinit_password, kinit_keytab + try: + from ipalib.install.kinit import kinit_password, kinit_keytab + except ImportError: + # pre 4.5.0 + from ipapython.ipautil import kinit_password, kinit_keytab from ipapython.ipautil import run from ipapython.ipautil import template_str from ipapython.dn import DN diff --git a/roles/ipaclient/library/ipaclient_get_otp.py b/roles/ipaclient/library/ipaclient_get_otp.py index d0642eb646..f78a9ef55e 100644 --- a/roles/ipaclient/library/ipaclient_get_otp.py +++ b/roles/ipaclient/library/ipaclient_get_otp.py @@ -89,9 +89,13 @@ from ipapython.ipautil import run from ipalib.constants import DEFAULT_CONFIG try: - from ipalib.install.kinit import kinit_password, kinit_keytab + from ipalib.kinit import kinit_password, kinit_keytab except ImportError: - from ipapython.ipautil import kinit_password, kinit_keytab + try: + from ipalib.install.kinit import kinit_password, kinit_keytab + except ImportError: + # pre 4.5.0 + from ipapython.ipautil import kinit_password, kinit_keytab except ImportError as _err: MODULE_IMPORT_ERROR = str(_err) else: diff --git a/roles/ipaclient/module_utils/ansible_ipa_client.py b/roles/ipaclient/module_utils/ansible_ipa_client.py index 649679fbaa..596ddfbacc 100644 --- a/roles/ipaclient/module_utils/ansible_ipa_client.py +++ b/roles/ipaclient/module_utils/ansible_ipa_client.py @@ -173,9 +173,13 @@ def knobs(self): ipa_generate_password from ipapython.dn import DN try: - from ipalib.install.kinit import kinit_keytab, kinit_password + from ipalib.kinit import kinit_password, kinit_keytab except ImportError: - from ipapython.ipautil import kinit_keytab, kinit_password + try: + from ipalib.install.kinit import kinit_keytab, kinit_password + except ImportError: + # pre 4.5.0 + from ipapython.ipautil import kinit_keytab, kinit_password from ipapython.ipa_log_manager import standard_logging_setup from gssapi.exceptions import GSSError try: diff --git a/roles/ipareplica/module_utils/ansible_ipa_replica.py b/roles/ipareplica/module_utils/ansible_ipa_replica.py index 76b7be2db7..f798833a8a 100644 --- a/roles/ipareplica/module_utils/ansible_ipa_replica.py +++ b/roles/ipareplica/module_utils/ansible_ipa_replica.py @@ -104,7 +104,10 @@ def getargspec(func): from ipaclient.install.ipachangeconf import IPAChangeConf from ipalib.install import certstore, sysrestore from ipapython.ipautil import ipa_generate_password - from ipalib.install.kinit import kinit_keytab + try: + from ipalib.kinit import kinit_keytab + except ImportError: + from ipalib.install.kinit import kinit_keytab from ipapython import ipaldap, ipautil, kernel_keyring from ipapython.certdb import IPA_CA_TRUST_FLAGS, \ EXTERNAL_CA_TRUST_FLAGS diff --git a/roles/ipaserver/library/ipaserver_get_connected_server.py b/roles/ipaserver/library/ipaserver_get_connected_server.py index c77144fdd7..2dc983fa2e 100644 --- a/roles/ipaserver/library/ipaserver_get_connected_server.py +++ b/roles/ipaserver/library/ipaserver_get_connected_server.py @@ -77,9 +77,13 @@ from ipapython.ipautil import run from ipalib.constants import DEFAULT_CONFIG try: - from ipalib.install.kinit import kinit_password + from ipalib.kinit import kinit_password except ImportError: - from ipapython.ipautil import kinit_password + try: + from ipalib.install.kinit import kinit_password + except ImportError: + # pre 4.5.0 + from ipapython.ipautil import kinit_password except ImportError as _err: MODULE_IMPORT_ERROR = str(_err) else: