Skip to content
Snippets Groups Projects
Commit af0b782f authored by Thomas Woerner's avatar Thomas Woerner
Browse files

topologysuffix: Use IPAAnsibleModule class

ipaadmin_variables are handled by IPAAnsibleModule,
ansible_module.params_get is used to get the parameters and
ansible_module.ipa_connect is used to simplify the module.
parent 5986de85
Branches
Tags
No related merge requests found
...@@ -31,13 +31,9 @@ DOCUMENTATION = """ ...@@ -31,13 +31,9 @@ DOCUMENTATION = """
module: ipatopologysuffix module: ipatopologysuffix
short description: Verify FreeIPA topology suffix short description: Verify FreeIPA topology suffix
description: Verify FreeIPA topology suffix description: Verify FreeIPA topology suffix
extends_documentation_fragment:
- ipamodule_base_docs
options: options:
ipaadmin_principal:
description: The admin principal
default: admin
ipaadmin_password:
description: The admin password
required: false
suffix: suffix:
description: Topology suffix description: Topology suffix
required: true required: true
...@@ -52,6 +48,7 @@ author: ...@@ -52,6 +48,7 @@ author:
EXAMPLES = """ EXAMPLES = """
- ipatopologysuffix: - ipatopologysuffix:
ipaadmin_password: SomeADMINpassword
suffix: domain suffix: domain
state: verified state: verified
""" """
...@@ -59,16 +56,12 @@ EXAMPLES = """ ...@@ -59,16 +56,12 @@ EXAMPLES = """
RETURN = """ RETURN = """
""" """
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.ansible_freeipa_module import IPAAnsibleModule
from ansible.module_utils._text import to_text
from ansible.module_utils.ansible_freeipa_module import execute_api_command
def main(): def main():
ansible_module = AnsibleModule( ansible_module = IPAAnsibleModule(
argument_spec=dict( argument_spec=dict(
ipaadmin_principal=dict(type="str", default="admin"),
ipaadmin_password=dict(type="str", required=False, no_log=True),
suffix=dict(choices=["domain", "ca"], required=True), suffix=dict(choices=["domain", "ca"], required=True),
state=dict(type="str", default="verified", state=dict(type="str", default="verified",
choices=["verified"]), choices=["verified"]),
...@@ -80,10 +73,8 @@ def main(): ...@@ -80,10 +73,8 @@ def main():
# Get parameters # Get parameters
ipaadmin_principal = ansible_module.params.get("ipaadmin_principal") suffix = ansible_module.params_get("suffix")
ipaadmin_password = ansible_module.params.get("ipaadmin_password") state = ansible_module.params_get("state")
suffix = ansible_module.params.get("suffix")
state = ansible_module.params.get("state")
# Check parameters # Check parameters
...@@ -91,16 +82,15 @@ def main(): ...@@ -91,16 +82,15 @@ def main():
# Create command # Create command
if state in ["verified"]: if state not in ["verified"]:
command = "topologysuffix_verify"
args = {}
else:
ansible_module.fail_json(msg="Unkown state '%s'" % state) ansible_module.fail_json(msg="Unkown state '%s'" % state)
# Execute command # Execute command
execute_api_command(ansible_module, ipaadmin_principal, ipaadmin_password, with ansible_module.ipa_connect():
command, to_text(suffix), args) # Execute command
ansible_module.ipa_command(["topologysuffix_verify", suffix,
{}])
# Done # Done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment