mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-30 19:34:45 +00:00
ipapwpolicy: Allow execution of plugin in client host.
Update pwpolicy README file and add tests for executing plugin with
`ipaapi_context` set to `client`.
A new test playbook can be found at:
tests/pwpolicy/test_pwpolicy_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:
@@ -98,6 +98,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 pwpolicy name strings. If name is not given, `global_policy` will be used automatically. | no
|
`name` \| `cn` | The list of pwpolicy name strings. If name is not given, `global_policy` will be used automatically. | no
|
||||||
`maxlife` \| `krbmaxpwdlife` | Maximum password lifetime in days. (int) | no
|
`maxlife` \| `krbmaxpwdlife` | Maximum password lifetime in days. (int) | no
|
||||||
`minlife` \| `krbminpwdlife` | Minimum password lifetime in hours. (int) | no
|
`minlife` \| `krbminpwdlife` | Minimum password lifetime in hours. (int) | no
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: Test pwpolicy
|
- name: Test pwpolicy
|
||||||
hosts: ipaserver
|
hosts: "{{ ipa_test_host | default('ipaserver') }}"
|
||||||
become: true
|
become: true
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
||||||
@@ -8,23 +8,27 @@
|
|||||||
- name: Ensure maxlife of 90 for global_policy
|
- name: Ensure maxlife of 90 for global_policy
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
maxlife: 90
|
maxlife: 90
|
||||||
|
|
||||||
- name: Ensure absence of group ops
|
- name: Ensure absence of group ops
|
||||||
ipagroup:
|
ipagroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: ops
|
name: ops
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Ensure absence of pwpolicies for group ops
|
- name: Ensure absence of pwpolicies for group ops
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: ops
|
name: ops
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Ensure presence of group ops
|
- name: Ensure presence of group ops
|
||||||
ipagroup:
|
ipagroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: ops
|
name: ops
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
@@ -33,6 +37,7 @@
|
|||||||
- name: Ensure presence of pwpolicies for group ops
|
- name: Ensure presence of pwpolicies for group ops
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: ops
|
name: ops
|
||||||
minlife: 7
|
minlife: 7
|
||||||
maxlife: 49
|
maxlife: 49
|
||||||
@@ -49,6 +54,7 @@
|
|||||||
- name: Ensure presence of pwpolicies for group ops again
|
- name: Ensure presence of pwpolicies for group ops again
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: ops
|
name: ops
|
||||||
minlife: 7
|
minlife: 7
|
||||||
maxlife: 49
|
maxlife: 49
|
||||||
@@ -65,6 +71,7 @@
|
|||||||
- name: Ensure maxlife of 49 for global_policy
|
- name: Ensure maxlife of 49 for global_policy
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
maxlife: 49
|
maxlife: 49
|
||||||
register: result
|
register: result
|
||||||
failed_when: not result.changed or result.failed
|
failed_when: not result.changed or result.failed
|
||||||
@@ -72,6 +79,7 @@
|
|||||||
- name: Ensure maxlife of 49 for global_policy again
|
- name: Ensure maxlife of 49 for global_policy again
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
maxlife: 49
|
maxlife: 49
|
||||||
register: result
|
register: result
|
||||||
failed_when: result.changed or result.failed
|
failed_when: result.changed or result.failed
|
||||||
@@ -79,6 +87,7 @@
|
|||||||
- name: Ensure absence of pwpoliciy global_policy will fail
|
- name: Ensure absence of pwpoliciy global_policy will fail
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
failed_when: not result.failed or "'global_policy' can not be made absent." not in result.msg
|
failed_when: not result.failed or "'global_policy' can not be made absent." not in result.msg
|
||||||
@@ -86,6 +95,7 @@
|
|||||||
- name: Ensure absence of pwpolicies for group ops
|
- name: Ensure absence of pwpolicies for group ops
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: ops
|
name: ops
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
@@ -94,6 +104,7 @@
|
|||||||
- name: Ensure maxlife of 90 for global_policy
|
- name: Ensure maxlife of 90 for global_policy
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
maxlife: 90
|
maxlife: 90
|
||||||
register: result
|
register: result
|
||||||
failed_when: not result.changed or result.failed
|
failed_when: not result.changed or result.failed
|
||||||
@@ -101,6 +112,7 @@
|
|||||||
- name: Ensure absence of pwpolicies for group ops
|
- name: Ensure absence of pwpolicies for group ops
|
||||||
ipapwpolicy:
|
ipapwpolicy:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: ops
|
name: ops
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|||||||
38
tests/pwpolicy/test_pwpolicy_client_context.yml
Normal file
38
tests/pwpolicy/test_pwpolicy_client_context.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
- name: Test pwpolicy
|
||||||
|
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.
|
||||||
|
ipapwpolicy:
|
||||||
|
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 pwpolicy using client context, in client host.
|
||||||
|
import_playbook: test_pwpolicy.yml
|
||||||
|
when: groups['ipaclients']
|
||||||
|
vars:
|
||||||
|
ipa_test_host: ipaclients
|
||||||
|
|
||||||
|
- name: Test pwpolicy using client context, in server host.
|
||||||
|
import_playbook: test_pwpolicy.yml
|
||||||
|
when: groups['ipaclients'] is not defined or not groups['ipaclients']
|
||||||
|
|
||||||
Reference in New Issue
Block a user