Skip to content

Commit 8007666

Browse files
committed
ipauser: Use PARAM_MAPPING and query state support
The ipauser module has been reworked to use the new PARAM_MAPPING added to ansible_freeipa_module. The member handling for manager, principal, certificate and certmapdata has been simplified by using gen_member_add_del_lists. The member entries in PARAM_MAPPING are now marked with "member": True. This replaces the manual calls to gen_add_del_lists, gen_add_list and gen_intersection_list across three separate action/state branches with a single unified call. The new query state allows to retrieve user information from IPA. The query_param option controls which fields are returned: BASE for essential fields, ALL for all fields, PKEY_ONLY for user names only, or a list of specific field names. Here is the updated documentation of the module: README-user.md New tests for the query state can be found at: tests/user/test_user_query.yml
1 parent e2ea26a commit 8007666

3 files changed

Lines changed: 664 additions & 508 deletions

File tree

README-user.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,100 @@ Example playbook to ensure users are absent:
368368
state: absent
369369
```
370370

371+
372+
Example playbook to query a user and print the base fields:
373+
374+
```yaml
375+
---
376+
- name: Playbook to query users
377+
hosts: ipaserver
378+
become: true
379+
380+
tasks:
381+
- name: Query user pinky
382+
ipauser:
383+
ipaadmin_password: SomeADMINpassword
384+
name: pinky
385+
state: query
386+
register: result
387+
388+
- name: Print user info
389+
debug:
390+
var: result.user
391+
```
392+
393+
394+
Example playbook to query specific fields of a user:
395+
396+
```yaml
397+
---
398+
- name: Playbook to query users
399+
hosts: ipaserver
400+
become: true
401+
402+
tasks:
403+
- name: Query first and last name of user pinky
404+
ipauser:
405+
ipaadmin_password: SomeADMINpassword
406+
name: pinky
407+
query_param:
408+
- first
409+
- last
410+
- email
411+
state: query
412+
register: result
413+
414+
- name: Print user info
415+
debug:
416+
var: result.user
417+
```
418+
419+
420+
Example playbook to query all fields of a user:
421+
422+
```yaml
423+
---
424+
- name: Playbook to query users
425+
hosts: ipaserver
426+
become: true
427+
428+
tasks:
429+
- name: Query all fields of user pinky
430+
ipauser:
431+
ipaadmin_password: SomeADMINpassword
432+
name: pinky
433+
query_param: ALL
434+
state: query
435+
register: result
436+
437+
- name: Print user info
438+
debug:
439+
var: result.user
440+
```
441+
442+
443+
Example playbook to query only the names of all users:
444+
445+
```yaml
446+
---
447+
- name: Playbook to query users
448+
hosts: ipaserver
449+
become: true
450+
451+
tasks:
452+
- name: Query all user names
453+
ipauser:
454+
ipaadmin_password: SomeADMINpassword
455+
query_param: PKEY_ONLY
456+
state: query
457+
register: result
458+
459+
- name: Print user names
460+
debug:
461+
var: result.user.users
462+
```
463+
464+
371465
When using FreeIPA 4.8.0+, SMB logon script, profile, home directory and home drive can be set for users.
372466

373467
In the example playbook to set SMB attributes note that `smb_profile_path` and `smb_home_dir` use paths in UNC format, which includes backslashes ('\\`). If the paths are quoted, the backslash needs to be escaped becoming "\\", so the path `\\server\dir` becomes `"\\\\server\\dir"`. If the paths are unquoted the slashes do not have to be escaped.

0 commit comments

Comments
 (0)