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

ipagroup: Allow execution of plugin in client host.

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

A new test playbook can be found at:

    tests/group/test_group_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 cf7b197a
No related branches found
No related tags found
No related merge requests found
...@@ -154,6 +154,7 @@ Variable | Description | Required ...@@ -154,6 +154,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` \| `cn` | The list of group name strings. | no `name` \| `cn` | The list of group name strings. | no
`description` | The group description string. | no `description` | The group description string. | no
`gid` \| `gidnumber` | The GID integer. | no `gid` \| `gidnumber` | The GID integer. | no
......
--- ---
- name: Test group - name: Test group
hosts: ipaserver hosts: "{{ ipa_test_host | default('ipaserver') }}"
become: true become: true
gather_facts: false gather_facts: false
...@@ -8,18 +8,21 @@ ...@@ -8,18 +8,21 @@
- name: Ensure users user1, user2 and user3 are absent - name: Ensure users user1, user2 and user3 are absent
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: user1,user2,user3 name: user1,user2,user3
state: absent state: absent
- name: Ensure group group3, group2 and group1 are absent - name: Ensure group group3, group2 and group1 are absent
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group3,group2,group1 name: group3,group2,group1
state: absent state: absent
- name: Ensure users user1..user3 are present - name: Ensure users user1..user3 are present
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
users: users:
- name: user1 - name: user1
first: user1 first: user1
...@@ -36,6 +39,7 @@ ...@@ -36,6 +39,7 @@
- name: Ensure group1 is present - name: Ensure group1 is present
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group1 name: group1
register: result register: result
failed_when: not result.changed or result.failed failed_when: not result.changed or result.failed
...@@ -43,6 +47,7 @@ ...@@ -43,6 +47,7 @@
- name: Ensure group1 is present again - name: Ensure group1 is present again
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group1 name: group1
register: result register: result
failed_when: result.changed or result.failed failed_when: result.changed or result.failed
...@@ -50,6 +55,7 @@ ...@@ -50,6 +55,7 @@
- name: Ensure group2 is present - name: Ensure group2 is present
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group2 name: group2
register: result register: result
failed_when: not result.changed or result.failed failed_when: not result.changed or result.failed
...@@ -57,6 +63,7 @@ ...@@ -57,6 +63,7 @@
- name: Ensure group2 is present again - name: Ensure group2 is present again
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group2 name: group2
register: result register: result
failed_when: result.changed or result.failed failed_when: result.changed or result.failed
...@@ -64,6 +71,7 @@ ...@@ -64,6 +71,7 @@
- name: Ensure group3 is present - name: Ensure group3 is present
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group3 name: group3
register: result register: result
failed_when: not result.changed or result.failed failed_when: not result.changed or result.failed
...@@ -71,6 +79,7 @@ ...@@ -71,6 +79,7 @@
- name: Ensure group3 is present again - name: Ensure group3 is present again
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group3 name: group3
register: result register: result
failed_when: result.changed or result.failed failed_when: result.changed or result.failed
...@@ -78,6 +87,7 @@ ...@@ -78,6 +87,7 @@
- name: Ensure groups group2 and group3 are present in group group1 - name: Ensure groups group2 and group3 are present in group group1
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group1 name: group1
group: group:
- group2 - group2
...@@ -89,6 +99,7 @@ ...@@ -89,6 +99,7 @@
- name: Ensure groups group2 and group3 are present in group group1 again - name: Ensure groups group2 and group3 are present in group group1 again
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group1 name: group1
group: group:
- group2 - group2
...@@ -100,6 +111,7 @@ ...@@ -100,6 +111,7 @@
- name: Ensure group3 ia present in group group1 - name: Ensure group3 ia present in group group1
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group1 name: group1
group: group:
- group3 - group3
...@@ -110,6 +122,7 @@ ...@@ -110,6 +122,7 @@
- name: Ensure users user1, user2 and user3 are present in group group1 - name: Ensure users user1, user2 and user3 are present in group group1
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group1 name: group1
user: user:
- user1 - user1
...@@ -122,6 +135,7 @@ ...@@ -122,6 +135,7 @@
- name: Ensure users user1, user2 and user3 are present in group group1 again - name: Ensure users user1, user2 and user3 are present in group group1 again
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group1 name: group1
user: user:
- user1 - user1
...@@ -133,6 +147,7 @@ ...@@ -133,6 +147,7 @@
#- ipagroup: #- ipagroup:
# ipaadmin_password: SomeADMINpassword # ipaadmin_password: SomeADMINpassword
# ipaapi_context: "{{ ipa_context | default(omit) }}"
# name: group1 # name: group1
# user: # user:
# - user7 # - user7
...@@ -141,6 +156,7 @@ ...@@ -141,6 +156,7 @@
- name: Ensure user user7 is absent in group group1 - name: Ensure user user7 is absent in group group1
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group1 name: group1
user: user:
- user7 - user7
...@@ -152,6 +168,7 @@ ...@@ -152,6 +168,7 @@
- name: Ensure group group4 is absent - name: Ensure group group4 is absent
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group4 name: group4
state: absent state: absent
register: result register: result
...@@ -160,6 +177,7 @@ ...@@ -160,6 +177,7 @@
- name: Ensure group group3, group2 and group1 are absent - name: Ensure group group3, group2 and group1 are absent
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: group3,group2,group1 name: group3,group2,group1
state: absent state: absent
register: result register: result
...@@ -168,8 +186,8 @@ ...@@ -168,8 +186,8 @@
- name: Ensure users user1, user2 and user3 are absent - name: Ensure users user1, user2 and user3 are absent
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: user1,user2,user3 name: user1,user2,user3
state: absent state: absent
register: result register: result
failed_when: not result.changed or result.failed failed_when: not result.changed or result.failed
---
- name: Test group
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.
ipagroup:
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 group using client context, in client host.
import_playbook: test_group.yml
when: groups['ipaclients']
vars:
ipa_test_host: ipaclients
- name: Test group using client context, in server host.
import_playbook: test_group.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