mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-25 00:44:42 +00:00
ipahostgroup: Allow execution of plugin in client host.
Update hostgroup README file and add tests for executing plugin with
`ipaapi_context` set to `client`.
A new test playbook can be found at:
tests/hostgroup/test_hostgroup_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:
@@ -150,6 +150,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 hostgroup name strings. | no
|
`name` \| `cn` | The list of hostgroup name strings. | no
|
||||||
`description` | The hostgroup description string. | no
|
`description` | The hostgroup description string. | no
|
||||||
`nomembers` | Suppress processing of membership attributes. (bool) | no
|
`nomembers` | Suppress processing of membership attributes. (bool) | no
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: Test hostgroup
|
- name: Test hostgroup
|
||||||
hosts: ipaserver
|
hosts: "{{ ipa_test_host | default('ipaserver') }}"
|
||||||
become: true
|
become: true
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
- name: Ensure host-group databases, mysql-server and oracle-server are absent
|
- name: Ensure host-group databases, mysql-server and oracle-server are absent
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name:
|
name:
|
||||||
- databases
|
- databases
|
||||||
- mysql-server
|
- mysql-server
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
- name: Test hosts db1 and db2 absent
|
- name: Test hosts db1 and db2 absent
|
||||||
ipahost:
|
ipahost:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name:
|
name:
|
||||||
- "{{ 'db1.' + ipaserver_domain }}"
|
- "{{ 'db1.' + ipaserver_domain }}"
|
||||||
- "{{ 'db2.' + ipaserver_domain }}"
|
- "{{ 'db2.' + ipaserver_domain }}"
|
||||||
@@ -30,6 +32,7 @@
|
|||||||
- name: Host "{{ 'db1.' + ipaserver_domain }}" present
|
- name: Host "{{ 'db1.' + ipaserver_domain }}" present
|
||||||
ipahost:
|
ipahost:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ 'db1.' + ipaserver_domain }}"
|
name: "{{ 'db1.' + ipaserver_domain }}"
|
||||||
force: yes
|
force: yes
|
||||||
register: result
|
register: result
|
||||||
@@ -38,6 +41,7 @@
|
|||||||
- name: Host "{{ 'db2.' + ipaserver_domain }}" present
|
- name: Host "{{ 'db2.' + ipaserver_domain }}" present
|
||||||
ipahost:
|
ipahost:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: "{{ 'db2.' + ipaserver_domain }}"
|
name: "{{ 'db2.' + ipaserver_domain }}"
|
||||||
force: yes
|
force: yes
|
||||||
register: result
|
register: result
|
||||||
@@ -46,6 +50,7 @@
|
|||||||
- name: Ensure host-group mysql-server is present
|
- name: Ensure host-group mysql-server is present
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: mysql-server
|
name: mysql-server
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
@@ -54,6 +59,7 @@
|
|||||||
- name: Ensure host-group mysql-server is present again
|
- name: Ensure host-group mysql-server is present again
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: mysql-server
|
name: mysql-server
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
@@ -62,6 +68,7 @@
|
|||||||
- name: Ensure host-group oracle-server is present
|
- name: Ensure host-group oracle-server is present
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: oracle-server
|
name: oracle-server
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
@@ -70,6 +77,7 @@
|
|||||||
- name: Ensure host-group oracle-server is present again
|
- name: Ensure host-group oracle-server is present again
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: oracle-server
|
name: oracle-server
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
@@ -78,6 +86,7 @@
|
|||||||
- name: Ensure host-group databases is present
|
- name: Ensure host-group databases is present
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: databases
|
name: databases
|
||||||
state: present
|
state: present
|
||||||
host:
|
host:
|
||||||
@@ -90,6 +99,7 @@
|
|||||||
- name: Ensure host-group databases is present again
|
- name: Ensure host-group databases is present again
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: databases
|
name: databases
|
||||||
state: present
|
state: present
|
||||||
host:
|
host:
|
||||||
@@ -102,6 +112,7 @@
|
|||||||
- name: Ensure host db2 is member of host-group databases
|
- name: Ensure host db2 is member of host-group databases
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: databases
|
name: databases
|
||||||
state: present
|
state: present
|
||||||
host:
|
host:
|
||||||
@@ -113,6 +124,7 @@
|
|||||||
- name: Ensure host db2 is member of host-group databases again
|
- name: Ensure host db2 is member of host-group databases again
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: databases
|
name: databases
|
||||||
state: present
|
state: present
|
||||||
host:
|
host:
|
||||||
@@ -124,6 +136,7 @@
|
|||||||
- name: Ensure host-group mysql-server is member of host-group databases
|
- name: Ensure host-group mysql-server is member of host-group databases
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: databases
|
name: databases
|
||||||
state: present
|
state: present
|
||||||
hostgroup:
|
hostgroup:
|
||||||
@@ -135,6 +148,7 @@
|
|||||||
- name: Ensure host-group mysql-server is member of host-group databases again
|
- name: Ensure host-group mysql-server is member of host-group databases again
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: databases
|
name: databases
|
||||||
state: present
|
state: present
|
||||||
hostgroup:
|
hostgroup:
|
||||||
@@ -146,6 +160,7 @@
|
|||||||
- name: Ensure host-group oracle-server is member of host-group databases (again)
|
- name: Ensure host-group oracle-server is member of host-group databases (again)
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name: databases
|
name: databases
|
||||||
state: present
|
state: present
|
||||||
hostgroup:
|
hostgroup:
|
||||||
@@ -157,6 +172,7 @@
|
|||||||
- name: Ensure host-group databases, mysql-server and oracle-server are absent
|
- name: Ensure host-group databases, mysql-server and oracle-server are absent
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name:
|
name:
|
||||||
- databases
|
- databases
|
||||||
- mysql-server
|
- mysql-server
|
||||||
@@ -168,6 +184,7 @@
|
|||||||
- name: Ensure host-group databases, mysql-server and oracle-server are absent again
|
- name: Ensure host-group databases, mysql-server and oracle-server are absent again
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name:
|
name:
|
||||||
- databases
|
- databases
|
||||||
- mysql-server
|
- mysql-server
|
||||||
@@ -179,6 +196,7 @@
|
|||||||
- name: Test hosts db1 and db2 absent
|
- name: Test hosts db1 and db2 absent
|
||||||
ipahost:
|
ipahost:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
ipaapi_context: "{{ ipa_context | default(omit) }}"
|
||||||
name:
|
name:
|
||||||
- "{{ 'db1.' + ipaserver_domain }}"
|
- "{{ 'db1.' + ipaserver_domain }}"
|
||||||
- "{{ 'db2.' + ipaserver_domain }}"
|
- "{{ 'db2.' + ipaserver_domain }}"
|
||||||
|
|||||||
37
tests/hostgroup/test_hostgroup_client_context.yml
Normal file
37
tests/hostgroup/test_hostgroup_client_context.yml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
- name: Test hostgroup
|
||||||
|
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.
|
||||||
|
ipahostgroup:
|
||||||
|
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 hostgroup using client context, in client host.
|
||||||
|
import_playbook: test_hostgroup.yml
|
||||||
|
when: groups['ipaclients']
|
||||||
|
vars:
|
||||||
|
ipa_test_host: ipaclients
|
||||||
|
|
||||||
|
- name: Test hostgroup using client context, in server host.
|
||||||
|
import_playbook: test_hostgroup.yml
|
||||||
|
when: groups['ipaclients'] is not defined or not groups['ipaclients']
|
||||||
Reference in New Issue
Block a user