mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-06 21:33:14 +00:00
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:
@@ -245,12 +245,17 @@ def main():
|
||||
rebuild_users = ansible_module.params_get("users")
|
||||
rebuild_hosts = ansible_module.params_get("hosts")
|
||||
|
||||
if (rebuild_hosts or rebuild_users) and state != "rebuild":
|
||||
ansible_module.fail_json(
|
||||
msg="'hosts' and 'users' are only valid with state: rebuild")
|
||||
if not automember_type and state != "rebuild":
|
||||
ansible_module.fail_json(
|
||||
msg="'automember_type' is required unless state: rebuild")
|
||||
# Check parameters
|
||||
invalid = []
|
||||
|
||||
if state != "rebuild":
|
||||
invalid = ["rebuild_hosts", "rebuild_users"]
|
||||
|
||||
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
|
||||
changed = False
|
||||
|
||||
Reference in New Issue
Block a user