mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-28 10:24:47 +00:00
New passkeyconfig management module
There is a new paskeyconfig management module placed in the plugins
folder:
plugins/modules/ipapasskeyconfig.py
The paskeyconfig module allows to retrieve and modify global passkey
configuration attributes.
Here is the documentation of the module:
README-passkeyconfig.md
New example playbooks have been added:
playbooks/passkeyconfig/passkeyconfig-retrieve.yml
playbooks/passkeyconfig/passkeyconfig-present.yml
New tests for the module can be found at:
tests/passkeyconfig/test_passkeyconfig.yml
tests/passkeyconfig/test_passkeyconfig_client_context.yml
Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
This commit is contained in:
67
tests/passkeyconfig/test_passkeyconfig.yml
Normal file
67
tests/passkeyconfig/test_passkeyconfig.yml
Normal file
@@ -0,0 +1,67 @@
|
||||
---
|
||||
- name: Test passkeyconfig
|
||||
hosts: "{{ ipa_test_host | default('ipaserver') }}"
|
||||
# It is normally not needed to set "become" to "true" for a module test.
|
||||
# Only set it to true if it is needed to execute commands as root.
|
||||
become: false
|
||||
# Enable "gather_facts" only if "ansible_facts" variable needs to be used.
|
||||
gather_facts: false
|
||||
module_defaults:
|
||||
ipapasskeyconfig:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Include FreeIPA facts.
|
||||
ansible.builtin.include_tasks: ../env_freeipa_facts.yml
|
||||
|
||||
- name: Run tests only if passkey is supported
|
||||
when: passkey_is_supported
|
||||
block:
|
||||
# TESTS
|
||||
|
||||
- name: Get current passkeyconfig
|
||||
ipapasskeyconfig:
|
||||
register: result_initial
|
||||
failed_when: result_initial.failed
|
||||
|
||||
- name: Ensure require_user_verification is set to false
|
||||
ipapasskeyconfig:
|
||||
require_user_verification: false
|
||||
register: result
|
||||
failed_when: result.failed
|
||||
|
||||
- name: Ensure require_user_verification is set to false again
|
||||
ipapasskeyconfig:
|
||||
require_user_verification: false
|
||||
register: result
|
||||
failed_when: result.changed or result.failed
|
||||
|
||||
- name: Verify require_user_verification is false
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.passkeyconfig.require_user_verification == false
|
||||
|
||||
- name: Ensure require_user_verification is set to true
|
||||
ipapasskeyconfig:
|
||||
require_user_verification: true
|
||||
register: result
|
||||
failed_when: not result.changed or result.failed
|
||||
|
||||
- name: Ensure require_user_verification is set to true again
|
||||
ipapasskeyconfig:
|
||||
require_user_verification: true
|
||||
register: result
|
||||
failed_when: result.changed or result.failed
|
||||
|
||||
- name: Verify require_user_verification is true
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.passkeyconfig.require_user_verification == true
|
||||
|
||||
# CLEANUP: Restore original configuration
|
||||
- name: Restore original passkeyconfig
|
||||
ipapasskeyconfig:
|
||||
require_user_verification: "{{ result_initial.passkeyconfig.require_user_verification }}"
|
||||
when: result_initial.passkeyconfig is defined and result_initial.passkeyconfig.require_user_verification is defined
|
||||
40
tests/passkeyconfig/test_passkeyconfig_client_context.yml
Normal file
40
tests/passkeyconfig/test_passkeyconfig_client_context.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
- name: Test passkeyconfig
|
||||
hosts: ipaclients, ipaserver
|
||||
# It is normally not needed to set "become" to "true" for a module test.
|
||||
# Only set it to true if it is needed to execute commands as root.
|
||||
become: false
|
||||
# Enable "gather_facts" only if "ansible_facts" variable needs to be used.
|
||||
gather_facts: false
|
||||
|
||||
tasks:
|
||||
- name: Include FreeIPA facts.
|
||||
ansible.builtin.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.
|
||||
ipapasskeyconfig:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: server
|
||||
require_user_verification: false
|
||||
register: result
|
||||
failed_when: not (result.failed and result.msg is regex("No module named '*ipaserver'*"))
|
||||
when: ipa_host_is_client and passkey_is_supported
|
||||
|
||||
# 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 passkeyconfig using client context, in client host.
|
||||
import_playbook: test_passkeyconfig.yml
|
||||
when: groups['ipaclients'] and passkey_is_supported
|
||||
vars:
|
||||
ipa_test_host: ipaclients
|
||||
|
||||
- name: Test passkeyconfig using client context, in server host.
|
||||
import_playbook: test_passkeyconfig.yml
|
||||
when: passkey_is_supported and (groups['ipaclients'] is not defined or not groups['ipaclients'])
|
||||
Reference in New Issue
Block a user