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

ipadelegation: Allow execution of plugin in client host.

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

A new test playbook can be found at:

    tests/delegation/test_delegation_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 65271a01
No related branches found
No related tags found
No related merge requests found
...@@ -142,6 +142,7 @@ Variable | Description | Required ...@@ -142,6 +142,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` \| `aciname` | The list of delegation name strings. | yes `name` \| `aciname` | The list of delegation name strings. | yes
`permission` \| `permissions` | The permission to grant `read`, `read,write`, `write`]. Default is `write`. | no `permission` \| `permissions` | The permission to grant `read`, `read,write`, `write`]. Default is `write`. | no
`attribute` \| `attrs` | The attribute list to which the delegation applies. | no `attribute` \| `attrs` | The attribute list to which the delegation applies. | no
......
--- ---
- name: Test delegation - name: Test delegation
hosts: ipaserver hosts: "{{ ipa_test_host | default('ipaserver') }}"
become: true become: true
tasks: tasks:
...@@ -10,12 +10,14 @@ ...@@ -10,12 +10,14 @@
- name: Ensure test groups are absent - name: Ensure test groups are absent
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: managers,managers2,employees,employees2 name: managers,managers2,employees,employees2
state: absent state: absent
- name: Ensure delegation "basic manager attributes" is absent - name: Ensure delegation "basic manager attributes" is absent
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
state: absent state: absent
...@@ -24,21 +26,25 @@ ...@@ -24,21 +26,25 @@
- name: Ensure test group managers is present - name: Ensure test group managers is present
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: managers name: managers
- name: Ensure test group managers2 is present - name: Ensure test group managers2 is present
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: managers2 name: managers2
- name: Ensure test group employees is present - name: Ensure test group employees is present
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: employees name: employees
- name: Ensure test group employees2 is present - name: Ensure test group employees2 is present
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: employees2 name: employees2
# TESTS # TESTS
...@@ -46,6 +52,7 @@ ...@@ -46,6 +52,7 @@
- name: Ensure delegation "basic manager attributes" is present - name: Ensure delegation "basic manager attributes" is present
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
permission: read permission: read
attribute: attribute:
...@@ -58,6 +65,7 @@ ...@@ -58,6 +65,7 @@
- name: Ensure delegation "basic manager attributes" is present again - name: Ensure delegation "basic manager attributes" is present again
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
permission: read permission: read
attribute: attribute:
...@@ -70,6 +78,7 @@ ...@@ -70,6 +78,7 @@
- name: Ensure delegation "basic manager attributes" is present with different attribute employeetype - name: Ensure delegation "basic manager attributes" is present with different attribute employeetype
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
permission: read permission: read
attribute: attribute:
...@@ -82,6 +91,7 @@ ...@@ -82,6 +91,7 @@
- name: Ensure delegation "basic manager attributes" is present with different attribute employeetype again - name: Ensure delegation "basic manager attributes" is present with different attribute employeetype again
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
permission: read permission: read
attribute: attribute:
...@@ -94,6 +104,7 @@ ...@@ -94,6 +104,7 @@
- name: Ensure delegation "basic manager attributes" member attribute departmentnumber is present - name: Ensure delegation "basic manager attributes" member attribute departmentnumber is present
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
attribute: attribute:
- departmentnumber - departmentnumber
...@@ -104,6 +115,7 @@ ...@@ -104,6 +115,7 @@
- name: Ensure delegation "basic manager attributes" member attribute departmentnumber is present again - name: Ensure delegation "basic manager attributes" member attribute departmentnumber is present again
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
attribute: attribute:
- departmentnumber - departmentnumber
...@@ -114,6 +126,7 @@ ...@@ -114,6 +126,7 @@
- name: Ensure delegation "basic manager attributes" member attributes employeetype and employeenumber are present - name: Ensure delegation "basic manager attributes" member attributes employeetype and employeenumber are present
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
attribute: attribute:
- employeetype - employeetype
...@@ -125,6 +138,7 @@ ...@@ -125,6 +138,7 @@
- name: Ensure delegation "basic manager attributes" member attributes employeetype and employeenumber are present again - name: Ensure delegation "basic manager attributes" member attributes employeetype and employeenumber are present again
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
attribute: attribute:
- employeetype - employeetype
...@@ -136,6 +150,7 @@ ...@@ -136,6 +150,7 @@
- name: Ensure delegation "basic manager attributes" member attributes employeenumber and employeetype are absent - name: Ensure delegation "basic manager attributes" member attributes employeenumber and employeetype are absent
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
attribute: attribute:
- employeenumber - employeenumber
...@@ -148,6 +163,7 @@ ...@@ -148,6 +163,7 @@
- name: Ensure delegation "basic manager attributes" member attributes employeenumber and employeetype are absent again - name: Ensure delegation "basic manager attributes" member attributes employeenumber and employeetype are absent again
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
attribute: attribute:
- employeenumber - employeenumber
...@@ -162,6 +178,7 @@ ...@@ -162,6 +178,7 @@
- name: Ensure delegation "basic manager attributes" is present with different read,write permission - name: Ensure delegation "basic manager attributes" is present with different read,write permission
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
permission: read,write permission: read,write
attribute: attribute:
...@@ -174,6 +191,7 @@ ...@@ -174,6 +191,7 @@
- name: Ensure delegation "basic manager attributes" is present with different read,write permission again - name: Ensure delegation "basic manager attributes" is present with different read,write permission again
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
permission: read,write permission: read,write
attribute: attribute:
...@@ -186,6 +204,7 @@ ...@@ -186,6 +204,7 @@
- name: Ensure delegation "basic manager attributes" is present with different group managers2 - name: Ensure delegation "basic manager attributes" is present with different group managers2
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
group: managers2 group: managers2
register: result register: result
...@@ -194,6 +213,7 @@ ...@@ -194,6 +213,7 @@
- name: Ensure delegation "basic manager attributes" is present with different group managers2 again - name: Ensure delegation "basic manager attributes" is present with different group managers2 again
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
group: managers2 group: managers2
register: result register: result
...@@ -202,6 +222,7 @@ ...@@ -202,6 +222,7 @@
- name: Ensure delegation "basic manager attributes" is present with different membergroup employees2 - name: Ensure delegation "basic manager attributes" is present with different membergroup employees2
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
membergroup: employees2 membergroup: employees2
register: result register: result
...@@ -210,6 +231,7 @@ ...@@ -210,6 +231,7 @@
- name: Ensure delegation "basic manager attributes" is present with different membergroup employees2 again - name: Ensure delegation "basic manager attributes" is present with different membergroup employees2 again
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
membergroup: employees2 membergroup: employees2
register: result register: result
...@@ -218,6 +240,7 @@ ...@@ -218,6 +240,7 @@
- name: Ensure delegation "basic manager attributes" fails with bad permission read,read - name: Ensure delegation "basic manager attributes" fails with bad permission read,read
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
permission: read,read permission: read,read
register: result register: result
...@@ -226,6 +249,7 @@ ...@@ -226,6 +249,7 @@
- name: Ensure delegation "basic manager attributes" fails with bad permission read,write,write - name: Ensure delegation "basic manager attributes" fails with bad permission read,write,write
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
permission: read,write,write permission: read,write,write
register: result register: result
...@@ -234,6 +258,7 @@ ...@@ -234,6 +258,7 @@
- name: Ensure delegation "basic manager attributes" fails with bad attribute businesscategory,businesscategory - name: Ensure delegation "basic manager attributes" fails with bad attribute businesscategory,businesscategory
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
attribute: attribute:
- businesscategory - businesscategory
...@@ -246,11 +271,13 @@ ...@@ -246,11 +271,13 @@
- name: Ensure delegation "basic manager attributes" is absent - name: Ensure delegation "basic manager attributes" is absent
ipadelegation: ipadelegation:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "basic manager attributes" name: "basic manager attributes"
state: absent state: absent
- name: Ensure test groups are absent - name: Ensure test groups are absent
ipagroup: ipagroup:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: managers,managers2,employees,employees2 name: managers,managers2,employees,employees2
state: absent state: absent
---
- name: Test delegation
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.
ipadelegation:
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 delegation using client context, in client host.
import_playbook: test_delegation.yml
when: groups['ipaclients']
vars:
ipa_test_host: ipaclients
- name: Test delegation using client context, in server host.
import_playbook: test_delegation.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