From 15f650ccaa31f5339e92858ed6de22aaf7e6b78f Mon Sep 17 00:00:00 2001
From: Thomas Woerner <twoerner@redhat.com>
Date: Thu, 4 Apr 2019 17:28:37 +0200
Subject: [PATCH] ipaclient: Fix issues with FreeIPA 4.6 and prior

check_ldap_conf is only available in FreeIPA 4.7 and later and
tasks.is_nosssd_supported is only available since 4.6.90.pre2.

check_ldap_conf is None (ansible_ipa_client) if it can not be imported.
hasattr has been added to check if is_nosssd_supported is a valid
attribute in tasks.

Fixes: #61 (ipaserver role - Fails on ipaclient install)
---
 roles/ipaclient/library/ipaclient_test.py | 32 ++++++++++++-----------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/roles/ipaclient/library/ipaclient_test.py b/roles/ipaclient/library/ipaclient_test.py
index 54bc2dfb..dda1c4cb 100644
--- a/roles/ipaclient/library/ipaclient_test.py
+++ b/roles/ipaclient/library/ipaclient_test.py
@@ -484,7 +484,8 @@ def main():
         #        "IPA client is already configured on this system.",
         #        rval=CLIENT_ALREADY_CONFIGURED)
 
-        check_ldap_conf()
+        if check_ldap_conf is not None:
+            check_ldap_conf()
 
         if options.conf_ntp:
             try:
@@ -526,21 +527,22 @@ def main():
                 "Invalid hostname, '{}' must not be used.".format(hostname),
                 rval=CLIENT_INSTALL_ERROR)
 
-        # --no-sssd is not supported any more for rhel-based distros
-        if not tasks.is_nosssd_supported() and not options.sssd:
-            raise ScriptError(
-                "Option '--no-sssd' is incompatible with the 'authselect' tool "
-                "provided by this distribution for configuring system "
-                "authentication resources",
-                rval=CLIENT_INSTALL_ERROR)
+        if hasattr(tasks, "is_nosssd_supported"):
+            # --no-sssd is not supported any more for rhel-based distros
+            if not tasks.is_nosssd_supported() and not options.sssd:
+                raise ScriptError(
+                    "Option '--no-sssd' is incompatible with the 'authselect' tool "
+                    "provided by this distribution for configuring system "
+                    "authentication resources",
+                    rval=CLIENT_INSTALL_ERROR)
 
-        # --noac is not supported any more for rhel-based distros
-        if not tasks.is_nosssd_supported() and options.no_ac:
-            raise ScriptError(
-                "Option '--noac' is incompatible with the 'authselect' tool "
-                "provided by this distribution for configuring system "
-                "authentication resources",
-                rval=CLIENT_INSTALL_ERROR)
+            # --noac is not supported any more for rhel-based distros
+            if not tasks.is_nosssd_supported() and options.no_ac:
+                raise ScriptError(
+                    "Option '--noac' is incompatible with the 'authselect' tool "
+                    "provided by this distribution for configuring system "
+                    "authentication resources",
+                    rval=CLIENT_INSTALL_ERROR)
 
         # when installing with '--no-sssd' option, check whether nss-ldap is
         # installed
-- 
GitLab