diff --git a/plugins/modules/ipahbacrule.py b/plugins/modules/ipahbacrule.py index 1d6a3b2fe4e881b883b9e66f015734e7fefef866..3547b95afc3e9eaa19d911caa9af8518bcc06a9b 100644 --- a/plugins/modules/ipahbacrule.py +++ b/plugins/modules/ipahbacrule.py @@ -247,6 +247,8 @@ def main(): # Check parameters + invalid = [] + if state == "present": if len(names) != 1: ansible_module.fail_json( @@ -254,11 +256,6 @@ def main(): if action == "member": invalid = ["description", "usercategory", "hostcategory", "servicecategory", "nomembers"] - for x in invalid: - if vars()[x] is not None: - ansible_module.fail_json( - msg="Argument '%s' can not be used with action " - "'%s'" % (x, action)) else: if hostcategory == 'all' and any([host, hostgroup]): ansible_module.fail_json( @@ -278,11 +275,6 @@ def main(): if action == "hbacrule": invalid.extend(["host", "hostgroup", "hbacsvc", "hbacsvcgroup", "user", "group"]) - for x in invalid: - if vars()[x] is not None: - ansible_module.fail_json( - msg="Argument '%s' can not be used with state '%s'" % - (x, state)) elif state in ["enabled", "disabled"]: if len(names) < 1: @@ -294,14 +286,11 @@ def main(): invalid = ["description", "usercategory", "hostcategory", "servicecategory", "nomembers", "host", "hostgroup", "hbacsvc", "hbacsvcgroup", "user", "group"] - for x in invalid: - if vars()[x] is not None: - ansible_module.fail_json( - msg="Argument '%s' can not be used with state '%s'" % - (x, state)) else: ansible_module.fail_json(msg="Invalid state '%s'" % state) + ansible_module.params_fail_used_invalid(invalid, state, action) + # Init changed = False