Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible_freeipa_module.IPAAnsibleModule: New execute_query method
This method enables to execute query state within IPAAnsibleModule. The parameter query_param canbe used to select the returned parameters. def execute_query(self, names, prefix, name_ipa_param, query_param, query_command, query_param_settings): """ Execute query state. Parameters ---------- names: The main items to return It names is not None and not an empty list then all items found with "item_find" are returned, else the items in names. prefix: The prefix for use with several main items The prefix is "users" for the "user" module. It is used if only the list of main items (example: users) is returned. name_ipa_param: The IPA param name of the name parameter This is for example "uid" that is used for the user name in the user module. query_param: The parameters to return The parameters that should be returned. If query_param is ["ALL"], all parameters in ipa_pram_names will be returned. query_param_settings: IPA base parameters, all and mapping The dict provides all parameters the "ALL" list and the mapping of the default module paramter name to IPA option name if it is not the same. Example: "uid" for user name of the user commands. query_command: The Query function This is a module function that returns the structure(s) from the show or find command. """ Add to DOCUMENTATION: query_param: description: The fields to query with state=query required: false state: description: State to ensure default: present choices: ["present", "absent", "query"] Add to the code: query_param_settings = { "ALL": [ "dn", "objectclass", "ipauniqueid", "ipantsecurityidentifier", "name", ... ], "BASE": [ "name", ... "disabled" ], "mapping": { "name": "uid", ... "disabled": "nsaccountock" } } def main(): ... invalid = [] if state == "present": ... else: ... if state == "query": if action == "member": module.fail_json( msg="Query is not possible with action=member") else: invalid.append("query_param") ... # Connect to IPA API with ansible_module.ipa_connect(): if state == "query": exit_args = ansible_module.execute_query( names, "users", "uid", query_param, user_find, query_param_settings) ansible_module.exit_json(changed=False, user=exit_args) # remainaing module code follows here
- Loading branch information