Skip to content

Commit

Permalink
ipatrust: Allow execution of plugin in client host.
Browse files Browse the repository at this point in the history
Update trust README file and add tests for executing plugin with
`ipaapi_context` set to `client`.

A new test playbook can be found at:

    tests/trust/test_trust_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.
  • Loading branch information
rjeffman committed Sep 28, 2021
1 parent 829f105 commit 577d8f7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions README-trust.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,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
`realm` | The realm name string. | yes
`admin` | Active Directory domain administrator string. | no
`password` | Active Directory domain administrator's password string. | no
Expand Down
4 changes: 3 additions & 1 deletion tests/trust/test_trust.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: find trust
hosts: ipaserver
hosts: "{{ ipa_test_host | default('ipaserver') }}"
become: true
gather_facts: false

Expand All @@ -11,6 +11,7 @@
- name: delete trust
ipatrust:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
realm: windows.local
state: absent
register: del_trust
Expand Down Expand Up @@ -38,6 +39,7 @@
- name: add trust
ipatrust:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
realm: windows.local
admin: Administrator
password: secret_ad_pw
Expand Down
38 changes: 38 additions & 0 deletions tests/trust/test_trust_client_context.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- name: Test trust
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.
ipatrust:
ipaadmin_password: SomeADMINpassword
ipaapi_context: server
realm: windows.local
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 trust using client context, in client host.
import_playbook: test_trust.yml
when: groups['ipaclients']
vars:
ipa_test_host: ipaclients

- name: Test trust using client context, in server host.
import_playbook: test_trust.yml
when: groups['ipaclients'] is not defined or not groups['ipaclients']

0 comments on commit 577d8f7

Please sign in to comment.