mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-06 13:23:14 +00:00
ipaautomountlocation: Allow execution of plugin in client host.
Update automountlocation README file and add tests for executing plugin
with `ipaapi_context` set to `client`.
A new test playbook can be found at:
tests/automountlocation/test_automountlocation_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:
@@ -88,7 +88,7 @@ Example playbook to ensure absence of an automount location:
|
||||
- name: ensure automount locations LOCATION1 and LOCATION2 do not exist
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
name:
|
||||
name:
|
||||
- LOCATION1
|
||||
- LOCATION2
|
||||
state: absent
|
||||
@@ -104,6 +104,7 @@ Variable | Description | Required
|
||||
-------- | ----------- | --------
|
||||
`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
|
||||
`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` \| `location` | List of one or more automountlocation names. | yes
|
||||
`state` | The state to ensure. It can be one of `present`, or `absent`, default: `present`. | no
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Test automountlocation
|
||||
hosts: ipaserver
|
||||
hosts: "{{ ipa_test_host | default('ipaserver') }}"
|
||||
become: true
|
||||
gather_facts: false
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
- name: ensure automountlocation TestLocations are absent before testing
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name:
|
||||
- TestLocation_01
|
||||
- TestLocation_02
|
||||
@@ -16,6 +17,7 @@
|
||||
- name: ensure empty automountlocation does nothing
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name: []
|
||||
state: present
|
||||
register: result
|
||||
@@ -24,6 +26,7 @@
|
||||
- name: ensure empty automountlocation does nothing on absent
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name: []
|
||||
state: absent
|
||||
register: result
|
||||
@@ -32,6 +35,7 @@
|
||||
- name: ensure automountlocation TestLocation is present
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name: TestLocation_01
|
||||
state: present
|
||||
register: result
|
||||
@@ -40,6 +44,7 @@
|
||||
- name: ensure automountlocation TestLocation is present again
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name: TestLocation_01
|
||||
state: present
|
||||
register: result
|
||||
@@ -48,6 +53,7 @@
|
||||
- name: ensure automountlocation TestLocation is absent
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name: TestLocation_01
|
||||
state: absent
|
||||
register: result
|
||||
@@ -56,6 +62,7 @@
|
||||
- name: ensure automountlocation TestLocation is absent again
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name: TestLocation_01
|
||||
state: absent
|
||||
register: result
|
||||
@@ -64,6 +71,7 @@
|
||||
- name: ensure a list of automountlocations are present
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name:
|
||||
- TestLocation_01
|
||||
- TestLocation_02
|
||||
@@ -74,6 +82,7 @@
|
||||
- name: ensure a list of automountlocations exist
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name:
|
||||
- TestLocation_01
|
||||
- TestLocation_02
|
||||
@@ -84,6 +93,7 @@
|
||||
- name: ensure a list of automountlocations are absent
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name:
|
||||
- TestLocation_01
|
||||
- TestLocation_02
|
||||
@@ -94,6 +104,7 @@
|
||||
- name: ensure multiple automountlocations are absent
|
||||
ipaautomountlocation:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||
name:
|
||||
- TestLocation_01
|
||||
- TestLocation_02
|
||||
|
||||
37
tests/automount/test_automountlocation_client_context.yml
Normal file
37
tests/automount/test_automountlocation_client_context.yml
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
- name: Test automountlocation
|
||||
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.
|
||||
ipaautomountlocation:
|
||||
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 automountlocation using client context, in client host.
|
||||
import_playbook: test_automountlocation.yml
|
||||
when: groups['ipaclients']
|
||||
vars:
|
||||
ipa_test_host: ipaclients
|
||||
|
||||
- name: Test automountlocation using client context, in server host.
|
||||
import_playbook: test_automountlocation.yml
|
||||
when: groups['ipaclients'] is not defined or not groups['ipaclients']
|
||||
Reference in New Issue
Block a user