diff --git a/README-trust.md b/README-trust.md index bc16bd3060..603303e1c4 100644 --- a/README-trust.md +++ b/README-trust.md @@ -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 diff --git a/tests/trust/test_trust.yml b/tests/trust/test_trust.yml index 581c6828d0..e4ecdf501d 100644 --- a/tests/trust/test_trust.yml +++ b/tests/trust/test_trust.yml @@ -1,6 +1,6 @@ --- - name: find trust - hosts: ipaserver + hosts: "{{ ipa_test_host | default('ipaserver') }}" become: true gather_facts: false @@ -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 @@ -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 diff --git a/tests/trust/test_trust_client_context.yml b/tests/trust/test_trust_client_context.yml new file mode 100644 index 0000000000..0b53cc53db --- /dev/null +++ b/tests/trust/test_trust_client_context.yml @@ -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'] +