Blame SOURCES/ansible-freeipa-0.1.8-ipahost-Enhanced-failure-msg-for-member-params-used-without-member-action_rhbz#1783948.patch

d9912c
From 24515e40ad289552d45bddd33c7a0dda93117a7f Mon Sep 17 00:00:00 2001
d9912c
From: Thomas Woerner <twoerner@redhat.com>
d9912c
Date: Wed, 18 Dec 2019 12:28:03 +0100
d9912c
Subject: [PATCH] ipahost: Enhanced failure msg for member params used without
d9912c
 member action
d9912c
d9912c
The failure message if member parameters like certificate, managedby_host,
d9912c
principal, allow_create_keytab_* and allow_retrieve_keytab_* are used
d9912c
without member action for state absent has been enhanced to propose the
d9912c
member action.
d9912c
---
d9912c
 plugins/modules/ipahost.py | 20 +++++++++++++-------
d9912c
 1 file changed, 13 insertions(+), 7 deletions(-)
d9912c
d9912c
diff --git a/plugins/modules/ipahost.py b/plugins/modules/ipahost.py
d9912c
index ec5e196..8ee9532 100644
d9912c
--- a/plugins/modules/ipahost.py
d9912c
+++ b/plugins/modules/ipahost.py
d9912c
@@ -511,19 +511,25 @@ def check_parameters(
d9912c
                    "userclass", "auth_ind", "requires_pre_auth",
d9912c
                    "ok_as_delegate", "ok_to_auth_as_delegate", "force",
d9912c
                    "reverse", "ip_address", "update_password"]
d9912c
+        for x in invalid:
d9912c
+            if vars()[x] is not None:
d9912c
+                module.fail_json(
d9912c
+                    msg="Argument '%s' can not be used with state '%s'" %
d9912c
+                    (x, state))
d9912c
         if action == "host":
d9912c
-            invalid.extend([
d9912c
+            invalid = [
d9912c
                 "certificate", "managedby_host", "principal",
d9912c
                 "allow_create_keytab_user", "allow_create_keytab_group",
d9912c
                 "allow_create_keytab_host", "allow_create_keytab_hostgroup",
d9912c
                 "allow_retrieve_keytab_user", "allow_retrieve_keytab_group",
d9912c
                 "allow_retrieve_keytab_host",
d9912c
-                "allow_retrieve_keytab_hostgroup"])
d9912c
-        for x in invalid:
d9912c
-            if vars()[x] is not None:
d9912c
-                module.fail_json(
d9912c
-                    msg="Argument '%s' can not be used with state '%s'" %
d9912c
-                    (x, state))
d9912c
+                "allow_retrieve_keytab_hostgroup"
d9912c
+            ]
d9912c
+            for x in invalid:
d9912c
+                if vars()[x] is not None:
d9912c
+                    module.fail_json(
d9912c
+                        msg="Argument '%s' can only be used with action "
d9912c
+                        "'member' for state '%s'" % (x, state))
d9912c
 
d9912c
 
d9912c
 def main():