Skip to content
Snippets Groups Projects
Commit 1440fb39 authored by Rafael Guterres Jeffman's avatar Rafael Guterres Jeffman
Browse files

ipalocation: Allow execution of plugin in client host.

Update location README file and add tests for executing plugin with
`ipaapi_context` set to `client`.

A new test playbook can be found at:

    tests/location/test_location_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.
parent 40f544ba
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,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` \| `idnsname` | The list of location name strings. | yes
`description` | The IPA location string | false
`state` | The state to ensure. It can be one of `present`, `absent`, default: `present`. | no
......
---
- name: Test location
hosts: ipaserver
hosts: "{{ ipa_test_host | default('ipaserver') }}"
become: true
tasks:
......@@ -10,6 +10,7 @@
- name: Ensure location my_location1 is absent
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: my_location1
state: absent
......@@ -20,6 +21,7 @@
- name: Ensure location my_location1 is present
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: my_location1
register: result
failed_when: not result.changed or result.failed
......@@ -27,6 +29,7 @@
- name: Ensure location my_location1 is present again
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: my_location1
register: result
failed_when: result.changed or result.failed
......@@ -34,6 +37,7 @@
- name: Ensure location my_location1 is present with description
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: my_location1
description: My Location 1
register: result
......@@ -42,6 +46,7 @@
- name: Ensure location my_location1 is present again with description
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: my_location1
description: My Location 1
register: result
......@@ -50,6 +55,7 @@
- name: Ensure location my_location1 is absent
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: my_location1
state: absent
register: result
......@@ -58,6 +64,7 @@
- name: Ensure location my_location1 is absent again
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: my_location1
state: absent
register: result
......@@ -68,5 +75,6 @@
- name: Ensure location my_location1 is absent
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: my_location1
state: absent
---
- name: Test location
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.
ipalocation:
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 location using client context, in client host.
import_playbook: test_location.yml
when: groups['ipaclients']
vars:
ipa_test_host: ipaclients
- name: Test location using client context, in server host.
import_playbook: test_location.yml
when: groups['ipaclients'] is not defined or not groups['ipaclients']
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment