-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT]: Add support for state:query to management modules #782
Open
t-woerner
wants to merge
3
commits into
freeipa:master
Choose a base branch
from
t-woerner:state_fetched
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t-woerner
changed the title
[DRAFT]: Add support for stete:fetched to user module
[DRAFT]: Add support for state:fetched to user module
Feb 25, 2022
t-woerner
force-pushed
the
state_fetched
branch
2 times, most recently
from
February 28, 2022 13:32
85e9363
to
7497eeb
Compare
@t-woerner Do you have a plan to add state: fetched for all users? |
t-woerner
force-pushed
the
state_fetched
branch
from
March 14, 2022 13:55
7497eeb
to
cedfc2a
Compare
/azp run Master and Pull Requests |
Azure Pipelines successfully started running 1 pipeline(s). |
t-woerner
force-pushed
the
state_fetched
branch
2 times, most recently
from
August 25, 2022 15:23
827c6ed
to
1246318
Compare
t-woerner
changed the title
[DRAFT]: Add support for state:fetched to user module
[DRAFT]: Add support for state:query to user module
Aug 25, 2022
t-woerner
force-pushed
the
state_fetched
branch
3 times, most recently
from
August 26, 2022 13:08
102736d
to
5f0e749
Compare
t-woerner
changed the title
[DRAFT]: Add support for state:query to user module
[DRAFT]: Add support for state:query to management module
Aug 26, 2022
t-woerner
changed the title
[DRAFT]: Add support for state:query to management module
[DRAFT]: Add support for state:query to management modules
Aug 26, 2022
t-woerner
force-pushed
the
state_fetched
branch
2 times, most recently
from
August 29, 2022 16:15
7985bac
to
864c54c
Compare
t-woerner
force-pushed
the
state_fetched
branch
2 times, most recently
from
September 28, 2023 13:13
43a5f70
to
3a79a44
Compare
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
The query_param parameter has been added, together with the dict query_param_settings. Also a new convert_result and user_find function has been added.
t-woerner
force-pushed
the
state_fetched
branch
from
September 28, 2023 13:20
3a79a44
to
54288e5
Compare
The query_param parameter has been added, together with the dict query_param_settings. The existing find_group function has been transformed into user_show to get the result for a single user and new convert_result and user_find function have been added.
t-woerner
force-pushed
the
state_fetched
branch
from
September 29, 2023 14:12
54288e5
to
f5dc843
Compare
This would be a very useful feature to add for hosts as well as users and groups. |
@arnoxit the plan is to add query support for all modules. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #660
Fixes #482