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()
Loading
Please register or sign in to comment