Skip to content
Snippets Groups Projects
Commit 27b50957 authored by Rafael Guterres Jeffman's avatar Rafael Guterres Jeffman
Browse files

ipauser: Allow execution of plugin in client host.

Update user README file and add tests for executing plugin with
`ipaapi_context` set to `client`.

A new test playbook can be found at:

    tests/user/test_user_client_context.yml

The new test file can be executed in a FreeIPA client host that is
not a server. In this case, it should be defined in the `ipaclients`
group, in the inventory file.
parent 577d8f78
No related branches found
No related tags found
No related merge requests found
...@@ -365,6 +365,7 @@ Variable | Description | Required ...@@ -365,6 +365,7 @@ Variable | Description | Required
-------- | ----------- | -------- -------- | ----------- | --------
`ipaadmin_principal` | The admin principal is a string and defaults to `admin` | no `ipaadmin_principal` | The admin principal is a string and defaults to `admin` | no
`ipaadmin_password` | The admin password is a string and is required if there is no admin ticket available on the node | no `ipaadmin_password` | The admin password is a string and is required if there is no admin ticket available on the node | no
`ipaapi_context` | The context in which the module will execute. Executing in a server context is preferred. If not provided context will be determined by the execution environment. Valid values are `server` and `client`. | no
`name` | The list of user name strings. `name` with *user variables* or `users` containing *user variables* need to be used. | no `name` | The list of user name strings. `name` with *user variables* or `users` containing *user variables* need to be used. | no
**User variables** | Only used with `name` variable in the first level. | no **User variables** | Only used with `name` variable in the first level. | no
`users` | The list of user dicts. Each `users` dict entry can contain **user variables**.<br>There is one required option in the `users` dict:| no `users` | The list of user dicts. Each `users` dict entry can contain **user variables**.<br>There is one required option in the `users` dict:| no
......
--- ---
- name: Test user - name: Test user
hosts: ipaserver hosts: "{{ ipa_test_host | default('ipaserver') }}"
become: true become: true
gather_facts: false gather_facts: false
...@@ -8,12 +8,14 @@ ...@@ -8,12 +8,14 @@
- name: Remove test users - name: Remove test users
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: manager1,manager2,manager3,pinky,pinky2 name: manager1,manager2,manager3,pinky,pinky2
state: absent state: absent
- name: User manager1 present - name: User manager1 present
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: manager1 name: manager1
first: Manager first: Manager
last: One last: One
...@@ -23,6 +25,7 @@ ...@@ -23,6 +25,7 @@
- name: User manager2 present - name: User manager2 present
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: manager2 name: manager2
first: Manager first: Manager
last: One last: One
...@@ -32,6 +35,7 @@ ...@@ -32,6 +35,7 @@
- name: User manager3 present - name: User manager3 present
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: manager3 name: manager3
first: Manager first: Manager
last: One last: One
...@@ -41,6 +45,7 @@ ...@@ -41,6 +45,7 @@
- name: User pinky present - name: User pinky present
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
uid: 10001 uid: 10001
gid: 100 gid: 100
...@@ -84,6 +89,7 @@ ...@@ -84,6 +89,7 @@
- name: User pinky present with changed settings - name: User pinky present with changed settings
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
first: pinky first: pinky
last: Acme last: Acme
...@@ -98,6 +104,7 @@ ...@@ -98,6 +104,7 @@
- name: User pinky add manager manager1 - name: User pinky add manager manager1
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
manager: manager1 manager: manager1
action: member action: member
...@@ -107,6 +114,7 @@ ...@@ -107,6 +114,7 @@
- name: User pinky add manager manager1 again - name: User pinky add manager manager1 again
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
manager: manager1 manager: manager1
action: member action: member
...@@ -116,6 +124,7 @@ ...@@ -116,6 +124,7 @@
- name: User pinky add manager manager2, manager3 - name: User pinky add manager manager2, manager3
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
manager: manager2,manager3 manager: manager2,manager3
action: member action: member
...@@ -125,6 +134,7 @@ ...@@ -125,6 +134,7 @@
- name: User pinky add manager manager2, manager3 again - name: User pinky add manager manager2, manager3 again
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
manager: manager2,manager3 manager: manager2,manager3
action: member action: member
...@@ -134,6 +144,7 @@ ...@@ -134,6 +144,7 @@
- name: User pinky remove manager manager1 - name: User pinky remove manager manager1
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
manager: manager1 manager: manager1
action: member action: member
...@@ -144,6 +155,7 @@ ...@@ -144,6 +155,7 @@
- name: User pinky remove manager manager1 again - name: User pinky remove manager manager1 again
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
manager: manager1 manager: manager1
action: member action: member
...@@ -154,6 +166,7 @@ ...@@ -154,6 +166,7 @@
- name: User pinky add principal pa - name: User pinky add principal pa
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
principal: pa principal: pa
action: member action: member
...@@ -163,6 +176,7 @@ ...@@ -163,6 +176,7 @@
- name: User pinky add principal pa again - name: User pinky add principal pa again
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
principal: pa principal: pa
action: member action: member
...@@ -172,6 +186,7 @@ ...@@ -172,6 +186,7 @@
- name: User pinky add principal pa1 - name: User pinky add principal pa1
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
principal: pa1 principal: pa1
action: member action: member
...@@ -181,6 +196,7 @@ ...@@ -181,6 +196,7 @@
- name: User pinky remove principal pa1 - name: User pinky remove principal pa1
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
principal: pa1 principal: pa1
action: member action: member
...@@ -191,6 +207,7 @@ ...@@ -191,6 +207,7 @@
- name: User pinky remove principal pa1 again - name: User pinky remove principal pa1 again
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
principal: pa1 principal: pa1
action: member action: member
...@@ -201,6 +218,7 @@ ...@@ -201,6 +218,7 @@
- name: User pinky remove principal pa - name: User pinky remove principal pa
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
principal: pa principal: pa
action: member action: member
...@@ -211,6 +229,7 @@ ...@@ -211,6 +229,7 @@
- name: User pinky remove principal non-existing pa2 - name: User pinky remove principal non-existing pa2
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
principal: pa2 principal: pa2
action: member action: member
...@@ -221,6 +240,7 @@ ...@@ -221,6 +240,7 @@
- name: User pinky absent and preserved - name: User pinky absent and preserved
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
preserve: yes preserve: yes
state: absent state: absent
...@@ -230,6 +250,7 @@ ...@@ -230,6 +250,7 @@
- name: User pinky undeleted (preserved before) - name: User pinky undeleted (preserved before)
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
state: undeleted state: undeleted
register: result register: result
...@@ -238,6 +259,7 @@ ...@@ -238,6 +259,7 @@
- name: Users pinky disabled - name: Users pinky disabled
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
state: disabled state: disabled
register: result register: result
...@@ -246,6 +268,7 @@ ...@@ -246,6 +268,7 @@
- name: User pinky enabled - name: User pinky enabled
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky name: pinky
state: enabled state: enabled
register: result register: result
...@@ -254,5 +277,6 @@ ...@@ -254,5 +277,6 @@
- name: Remove test users - name: Remove test users
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: manager1,manager2,manager3,pinky,pinky2 name: manager1,manager2,manager3,pinky,pinky2
state: absent state: absent
---
- name: Test user
hosts: ipaclients, ipaserver
become: no
gather_facts: no
tasks:
- name: Include FreeIPA facts.
include_tasks: ../env_freeipa_facts.yml
# Test will only be executed if host is not a server.
- name: Execute with server context in the client.
ipauser:
ipaadmin_password: SomeADMINpassword
ipaapi_context: server
name: ThisShouldNotWork
register: result
failed_when: not (result.failed and result.msg is regex("No module named '*ipaserver'*"))
when: ipa_host_is_client
# Import basic module tests, and execute with ipa_context set to 'client'.
# If ipaclients is set, it will be executed using the client, if not,
# ipaserver will be used.
#
# With this setup, tests can be executed against an IPA client, against
# an IPA server using "client" context, and ensure that tests are executed
# in upstream CI.
- name: Test user using client context, in client host.
import_playbook: test_user.yml
when: groups['ipaclients']
vars:
ipa_test_host: ipaclients
- name: Test user using client context, in server host.
import_playbook: test_user.yml
when: groups['ipaclients'] is not defined or not groups['ipaclients']
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment