mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-25 00:44:42 +00:00
ipaautomember: Allow execution of plugin in client host.
Update automember README file and add tests for executing plugin with
`ipaapi_context` set to `client`.
A new test playbook can be found at:
tests/automember/test_automember_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.
This commit is contained in:
@@ -122,6 +122,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` | Automember rule. | yes
|
`name` \| `cn` | Automember rule. | yes
|
||||||
`description` | A description of this auto member rule. | no
|
`description` | A description of this auto member rule. | no
|
||||||
`automember_type` | Grouping to which the rule applies. It can be one of `group`, `hostgroup`. | yes
|
`automember_type` | Grouping to which the rule applies. It can be one of `group`, `hostgroup`. | yes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: Test automember
|
- name: Test automember
|
||||||
hosts: ipaserver
|
hosts: "{{ ipa_test_host | default('ipaserver') }}"
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
@@ -10,18 +10,21 @@
|
|||||||
- name: Ensure group testgroup is absent
|
- name: Ensure group testgroup is absent
|
||||||
ipagroup:
|
ipagroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Ensure hostgroup testhostgroup is absent
|
- name: Ensure hostgroup testhostgroup is absent
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Ensure group automember rule testgroup is absent
|
- name: Ensure group automember rule testgroup is absent
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
state: absent
|
state: absent
|
||||||
automember_type: group
|
automember_type: group
|
||||||
@@ -29,6 +32,7 @@
|
|||||||
- name: Ensure hostgroup automember rule testhostgroup is absent
|
- name: Ensure hostgroup automember rule testhostgroup is absent
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
state: absent
|
state: absent
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
@@ -39,16 +43,19 @@
|
|||||||
- name: Ensure testgroup group is present
|
- name: Ensure testgroup group is present
|
||||||
ipagroup:
|
ipagroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
|
|
||||||
- name: Ensure testhostgroup hostgroup is present
|
- name: Ensure testhostgroup hostgroup is present
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
|
|
||||||
- name: Ensure testgroup group automember rule is present
|
- name: Ensure testgroup group automember rule is present
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
description: testgroup automember rule.
|
description: testgroup automember rule.
|
||||||
automember_type: group
|
automember_type: group
|
||||||
@@ -58,6 +65,7 @@
|
|||||||
- name: Ensure testgroup group automember rule is present again
|
- name: Ensure testgroup group automember rule is present again
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
description: testgroup automember rule.
|
description: testgroup automember rule.
|
||||||
automember_type: group
|
automember_type: group
|
||||||
@@ -67,6 +75,7 @@
|
|||||||
- name: Change testgroup group automember rule description
|
- name: Change testgroup group automember rule description
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
description: testgroup automember rule description.
|
description: testgroup automember rule description.
|
||||||
automember_type: group
|
automember_type: group
|
||||||
@@ -76,6 +85,7 @@
|
|||||||
- name: Ensure testgroup group automember rule has conditions
|
- name: Ensure testgroup group automember rule has conditions
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
automember_type: group
|
automember_type: group
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -92,6 +102,7 @@
|
|||||||
- name: Ensure testgroup group automember rule has conditions again
|
- name: Ensure testgroup group automember rule has conditions again
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
automember_type: group
|
automember_type: group
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -108,6 +119,7 @@
|
|||||||
- name: Add testgroup group automember rule member condition
|
- name: Add testgroup group automember rule member condition
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
automember_type: group
|
automember_type: group
|
||||||
action: member
|
action: member
|
||||||
@@ -120,6 +132,7 @@
|
|||||||
- name: Ensure testgroup group automember rule has conditions
|
- name: Ensure testgroup group automember rule has conditions
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
automember_type: group
|
automember_type: group
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -138,6 +151,7 @@
|
|||||||
- name: Remove testgroup group automember rule member condition
|
- name: Remove testgroup group automember rule member condition
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
automember_type: group
|
automember_type: group
|
||||||
action: member
|
action: member
|
||||||
@@ -151,6 +165,7 @@
|
|||||||
- name: Ensure testgroup group automember rule has conditions again
|
- name: Ensure testgroup group automember rule has conditions again
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
automember_type: group
|
automember_type: group
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -168,6 +183,7 @@
|
|||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_principal: admin
|
ipaadmin_principal: admin
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
automember_type: group
|
automember_type: group
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -182,6 +198,7 @@
|
|||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_principal: admin
|
ipaadmin_principal: admin
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
automember_type: group
|
automember_type: group
|
||||||
exclusive:
|
exclusive:
|
||||||
@@ -195,6 +212,7 @@
|
|||||||
- name: Ensure testhostgroup hostgroup automember rule is present
|
- name: Ensure testhostgroup hostgroup automember rule is present
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
description: testhostgroup automember rule
|
description: testhostgroup automember rule
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
@@ -204,6 +222,7 @@
|
|||||||
- name: Ensure testhostgroup hostgroup automember rule is present again
|
- name: Ensure testhostgroup hostgroup automember rule is present again
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
description: testhostgroup automember rule
|
description: testhostgroup automember rule
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
@@ -213,6 +232,7 @@
|
|||||||
- name: Change testhostgroup hostgroup automember rule description
|
- name: Change testhostgroup hostgroup automember rule description
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
description: testhostgroup test automember rule
|
description: testhostgroup test automember rule
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
@@ -222,6 +242,7 @@
|
|||||||
- name: Ensure testhostgroup hostgroup automember rule has conditions
|
- name: Ensure testhostgroup hostgroup automember rule has conditions
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -238,6 +259,7 @@
|
|||||||
- name: Ensure testhostgroup hostgroup automember rule has conditions again
|
- name: Ensure testhostgroup hostgroup automember rule has conditions again
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -254,6 +276,7 @@
|
|||||||
- name: Add testhostgroup hostgroup automember rule member condition
|
- name: Add testhostgroup hostgroup automember rule member condition
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
action: member
|
action: member
|
||||||
@@ -266,6 +289,7 @@
|
|||||||
- name: Ensure testhostgroup hostgroup automember rule has conditions
|
- name: Ensure testhostgroup hostgroup automember rule has conditions
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -284,6 +308,7 @@
|
|||||||
- name: Remove testhostgroup hostgroup automember rule member condition
|
- name: Remove testhostgroup hostgroup automember rule member condition
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
action: member
|
action: member
|
||||||
@@ -297,6 +322,7 @@
|
|||||||
- name: Ensure testhostgroup hostgroup automember rule has conditions
|
- name: Ensure testhostgroup hostgroup automember rule has conditions
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -315,6 +341,7 @@
|
|||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_principal: admin
|
ipaadmin_principal: admin
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
inclusive:
|
inclusive:
|
||||||
@@ -329,6 +356,7 @@
|
|||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_principal: admin
|
ipaadmin_principal: admin
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
exclusive:
|
exclusive:
|
||||||
@@ -344,18 +372,21 @@
|
|||||||
- name: Ensure group testgroup is absent
|
- name: Ensure group testgroup is absent
|
||||||
ipagroup:
|
ipagroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testgroup
|
name: testgroup
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Ensure hostgroup testhostgroup is absent
|
- name: Ensure hostgroup testhostgroup is absent
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Ensure group automember rule testgroup is absent
|
- name: Ensure group automember rule testgroup is absent
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
automember_type: group
|
automember_type: group
|
||||||
name: testgroup
|
name: testgroup
|
||||||
state: absent
|
state: absent
|
||||||
@@ -363,6 +394,7 @@
|
|||||||
- name: Ensure hostgroup automember rule testhostgroup is absent
|
- name: Ensure hostgroup automember rule testhostgroup is absent
|
||||||
ipaautomember:
|
ipaautomember:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
automember_type: hostgroup
|
automember_type: hostgroup
|
||||||
name: testhostgroup
|
name: testhostgroup
|
||||||
state: absent
|
state: absent
|
||||||
|
|||||||
38
tests/automember/test_automember_client_context.yml
Normal file
38
tests/automember/test_automember_client_context.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
- name: Test automember
|
||||||
|
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.
|
||||||
|
ipaautomember:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: server
|
||||||
|
name: ThisShouldNotWork
|
||||||
|
state: rebuild
|
||||||
|
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 automember using client context, in client host.
|
||||||
|
import_playbook: test_automember.yml
|
||||||
|
when: groups['ipaclients']
|
||||||
|
vars:
|
||||||
|
ipa_test_host: ipaclients
|
||||||
|
|
||||||
|
- name: Test automember using client context, in server host.
|
||||||
|
import_playbook: test_automember.yml
|
||||||
|
when: groups['ipaclients'] is not defined or not groups['ipaclients']
|
||||||
Reference in New Issue
Block a user