automember: 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:
Rafael Guterres Jeffman
2021-09-30 21:12:03 -03:00
parent 3dd9855916
commit 23e38fae27

View File

@@ -245,12 +245,17 @@ def main():
rebuild_users = ansible_module.params_get("users") rebuild_users = ansible_module.params_get("users")
rebuild_hosts = ansible_module.params_get("hosts") rebuild_hosts = ansible_module.params_get("hosts")
if (rebuild_hosts or rebuild_users) and state != "rebuild": # Check parameters
ansible_module.fail_json( invalid = []
msg="'hosts' and 'users' are only valid with state: rebuild")
if not automember_type and state != "rebuild": if state != "rebuild":
ansible_module.fail_json( invalid = ["rebuild_hosts", "rebuild_users"]
msg="'automember_type' is required unless state: rebuild")
if not automember_type and state != "rebuild":
ansible_module.fail_json(
msg="'automember_type' is required unless state: rebuild")
ansible_module.params_fail_used_invalid(invalid, state, action)
# Init # Init
changed = False changed = False