Skip to content
Commit d01c42d7 authored by Thomas Woerner's avatar Thomas Woerner
Browse files

ansible_freeipa_module: New IPAAnsibleModule class

This class is an extended version of the Ansible Module that provides
IPA specific methods to simplify module generation.

Simple example:

    from ansible.module_utils.ansible_freeipa_module import \
        IPAAnsibleModule

    def main():
        ansible_module = IPAAnsibleModule(
            argument_spec=dict(
                  name=dict(type="str", aliases=["cn"], default=None),
                  state=dict(type="str", default="present",
                             choices=["present", "absent"]),
            ),
        )

        # Get parameters
        name = ansible_module.params_get("name")
        state = ansible_module.params_get("state")

        # Connect to IPA API
        with ansible_module.ipa_connect():

            # Execute command
            if state == "present":
                ansible_module.ipa_command(["command_add", name, {}])
            else:
                ansible_module.ipa_command(["command_del", name, {}])

        # Done

        ansible_module.exit_json(changed=True)

    if __name__ == "__main__":
        main()
parent 53dbc59f
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment