mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-08-01 12:24:43 +00:00
ipaserver: Allow execution of plugin in client host.
Update server README file and add tests for executing plugin with
`ipaapi_context` set to `client`.
A new test playbook can be found at:
tests/server/test_server_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:
@@ -230,6 +230,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 server name strings. | yes
|
`name` \| `cn` | The list of server name strings. | yes
|
||||||
`location` \| `ipalocation_location` | The server location string. Only in state: present. "" for location reset. | no
|
`location` \| `ipalocation_location` | The server location string. Only in state: present. "" for location reset. | no
|
||||||
`service_weight` \| `ipaserviceweight` | Weight for server services. Type Values 0 to 65535, -1 for weight reset. Only in state: present. (int) | no
|
`service_weight` \| `ipaserviceweight` | Weight for server services. Type Values 0 to 65535, -1 for weight reset. Only in state: present. (int) | no
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: Test server
|
- name: Test server
|
||||||
hosts: ipaserver
|
hosts: "{{ ipa_test_host | default('ipaserver') }}"
|
||||||
become: true
|
become: true
|
||||||
gather_facts: yes
|
gather_facts: yes
|
||||||
|
|
||||||
@@ -30,18 +30,21 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without location
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without location
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
location: ""
|
location: ""
|
||||||
|
|
||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without service weight
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without service weight
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
service_weight: -1
|
service_weight: -1
|
||||||
|
|
||||||
- name: Ensure location "mylocation" is absent
|
- name: Ensure location "mylocation" is absent
|
||||||
ipalocation:
|
ipalocation:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: mylocation
|
name: mylocation
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
@@ -50,6 +53,7 @@
|
|||||||
- name: Ensure location "mylocation" is present
|
- name: Ensure location "mylocation" is present
|
||||||
ipalocation:
|
ipalocation:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: mylocation
|
name: mylocation
|
||||||
register: result
|
register: result
|
||||||
failed_when: not result.changed or result.failed
|
failed_when: not result.changed or result.failed
|
||||||
@@ -59,6 +63,7 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" is present
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" is present
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
register: result
|
register: result
|
||||||
failed_when: result.changed or result.failed
|
failed_when: result.changed or result.failed
|
||||||
@@ -66,6 +71,7 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with location "mylocation"
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with location "mylocation"
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
location: "mylocation"
|
location: "mylocation"
|
||||||
register: result
|
register: result
|
||||||
@@ -74,6 +80,7 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with location "mylocation" again
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with location "mylocation" again
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
location: "mylocation"
|
location: "mylocation"
|
||||||
register: result
|
register: result
|
||||||
@@ -82,6 +89,7 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without location
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without location
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
location: ""
|
location: ""
|
||||||
register: result
|
register: result
|
||||||
@@ -90,6 +98,7 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without location again
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without location again
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
location: ""
|
location: ""
|
||||||
register: result
|
register: result
|
||||||
@@ -98,6 +107,7 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with service weight 1
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with service weight 1
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
service_weight: 1
|
service_weight: 1
|
||||||
register: result
|
register: result
|
||||||
@@ -106,6 +116,7 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with service weight 1 again
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with service weight 1 again
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
service_weight: 1
|
service_weight: 1
|
||||||
register: result
|
register: result
|
||||||
@@ -114,6 +125,7 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without service weight
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without service weight
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
service_weight: -1
|
service_weight: -1
|
||||||
register: result
|
register: result
|
||||||
@@ -122,6 +134,7 @@
|
|||||||
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without service weight again
|
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without service weight again
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
|
||||||
service_weight: -1
|
service_weight: -1
|
||||||
register: result
|
register: result
|
||||||
@@ -134,6 +147,7 @@
|
|||||||
- name: Ensure server "{{ 'absent.' + ipaserver_domain }}" is absent
|
- name: Ensure server "{{ 'absent.' + ipaserver_domain }}" is absent
|
||||||
ipaserver:
|
ipaserver:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ 'absent.' + ipaserver_domain }}"
|
name: "{{ 'absent.' + ipaserver_domain }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
@@ -148,6 +162,7 @@
|
|||||||
- name: Ensure location "mylocation" is absent
|
- name: Ensure location "mylocation" is absent
|
||||||
ipalocation:
|
ipalocation:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: mylocation
|
name: mylocation
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|||||||
37
tests/server/test_server_client_context.yml
Normal file
37
tests/server/test_server_client_context.yml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
- name: Test server
|
||||||
|
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.
|
||||||
|
ipaserver:
|
||||||
|
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 server using client context, in client host.
|
||||||
|
import_playbook: test_server.yml
|
||||||
|
when: groups['ipaclients']
|
||||||
|
vars:
|
||||||
|
ipa_test_host: ipaclients
|
||||||
|
|
||||||
|
- name: Test server using client context, in server host.
|
||||||
|
import_playbook: test_server.yml
|
||||||
|
when: groups['ipaclients'] is not defined or not groups['ipaclients']
|
||||||
Reference in New Issue
Block a user