mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-08-02 04:44:42 +00:00
hbacrule: Use IPAAnsibleModule method to validate arguments.
Use the IPAAnsibleModule.params_fail_if_used method to validate arguments provided by user.
This commit is contained in:
@@ -247,6 +247,8 @@ def main():
|
|||||||
|
|
||||||
# Check parameters
|
# Check parameters
|
||||||
|
|
||||||
|
invalid = []
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
if len(names) != 1:
|
if len(names) != 1:
|
||||||
ansible_module.fail_json(
|
ansible_module.fail_json(
|
||||||
@@ -254,11 +256,6 @@ def main():
|
|||||||
if action == "member":
|
if action == "member":
|
||||||
invalid = ["description", "usercategory", "hostcategory",
|
invalid = ["description", "usercategory", "hostcategory",
|
||||||
"servicecategory", "nomembers"]
|
"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:
|
else:
|
||||||
if hostcategory == 'all' and any([host, hostgroup]):
|
if hostcategory == 'all' and any([host, hostgroup]):
|
||||||
ansible_module.fail_json(
|
ansible_module.fail_json(
|
||||||
@@ -278,11 +275,6 @@ def main():
|
|||||||
if action == "hbacrule":
|
if action == "hbacrule":
|
||||||
invalid.extend(["host", "hostgroup", "hbacsvc", "hbacsvcgroup",
|
invalid.extend(["host", "hostgroup", "hbacsvc", "hbacsvcgroup",
|
||||||
"user", "group"])
|
"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"]:
|
elif state in ["enabled", "disabled"]:
|
||||||
if len(names) < 1:
|
if len(names) < 1:
|
||||||
@@ -294,14 +286,11 @@ def main():
|
|||||||
invalid = ["description", "usercategory", "hostcategory",
|
invalid = ["description", "usercategory", "hostcategory",
|
||||||
"servicecategory", "nomembers", "host", "hostgroup",
|
"servicecategory", "nomembers", "host", "hostgroup",
|
||||||
"hbacsvc", "hbacsvcgroup", "user", "group"]
|
"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:
|
else:
|
||||||
ansible_module.fail_json(msg="Invalid state '%s'" % state)
|
ansible_module.fail_json(msg="Invalid state '%s'" % state)
|
||||||
|
|
||||||
|
ansible_module.params_fail_used_invalid(invalid, state, action)
|
||||||
|
|
||||||
# Init
|
# Init
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|||||||
Reference in New Issue
Block a user