-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New utils method that returns the lists of members.
Extend netgroup and sudorule modules to support external users and hosts wherever possible. Add tests for ipanetgroup and ipasudorule. Signed-off-by: Denis Karpelevich <[email protected]>
- Loading branch information
Showing
7 changed files
with
513 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
--- | ||
|
||
- name: Test netgroup with external members | ||
hosts: "{{ ipa_test_host | default('ipaserver') }}" | ||
become: true | ||
gather_facts: true | ||
remote_user: root | ||
|
||
tasks: | ||
- name: Test netgroup with external members | ||
block: | ||
# setup | ||
- name: Ensure netgroups are absent | ||
ipanetgroup: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: | ||
- testnetgroup1 | ||
- testnetgroup2 | ||
state: absent | ||
|
||
- name: Ensure external host is absent | ||
ipahost: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: | ||
- external.host | ||
state: absent | ||
|
||
- name: Ensure host is present | ||
ipahost: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: "{{ ansible_facts['fqdn'] }}" | ||
|
||
- name: Ensure netgroup testnetgroup2 is present | ||
ipanetgroup: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: testnetgroup2 | ||
|
||
# tests | ||
- name: Ensure netgroup is present with hosts (action netgroup) | ||
ipanetgroup: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: testnetgroup1 | ||
host: | ||
- "{{ ansible_facts['fqdn'] }}" | ||
- external.host | ||
register: result | ||
failed_when: not result.changed or result.failed | ||
|
||
- name: Ensure netgroup is present with hosts (action netgroup) again | ||
ipanetgroup: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: testnetgroup1 | ||
host: | ||
- "{{ ansible_facts['fqdn'] }}" | ||
- external.host | ||
register: result | ||
failed_when: result.changed or result.failed | ||
|
||
- name: Ensure netgroup is present with hosts (action member) | ||
ipanetgroup: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: testnetgroup2 | ||
host: | ||
- "{{ ansible_facts['fqdn'] }}" | ||
- external.host | ||
action: member | ||
register: result | ||
failed_when: not result.changed or result.failed | ||
|
||
- name: Ensure netgroup is present with hosts (action member) again | ||
ipanetgroup: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: testnetgroup2 | ||
host: | ||
- "{{ ansible_facts['fqdn'] }}" | ||
- external.host | ||
action: member | ||
register: result | ||
failed_when: result.changed or result.failed | ||
|
||
- name: Ensure hosts are absent in netgroup (action member) | ||
ipanetgroup: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: testnetgroup2 | ||
host: | ||
- "{{ ansible_facts['fqdn'] }}" | ||
- external.host | ||
action: member | ||
state: absent | ||
register: result | ||
failed_when: not result.changed or result.failed | ||
|
||
- name: Ensure hosts are absent in netgroup (action member) again | ||
ipanetgroup: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: testnetgroup2 | ||
host: | ||
- "{{ ansible_facts['fqdn'] }}" | ||
- external.host | ||
action: member | ||
state: absent | ||
register: result | ||
failed_when: result.changed or result.failed | ||
|
||
always: | ||
# cleanup | ||
- name: Ensure netgroups are absent | ||
ipanetgroup: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: | ||
- testnetgroup1 | ||
- testnetgroup2 | ||
state: absent | ||
|
||
- name: Ensure external host is absent | ||
ipahost: | ||
ipaadmin_password: SomeADMINpassword | ||
ipaapi_context: "{{ ipa_context | default(omit) }}" | ||
name: | ||
- external.host | ||
state: absent |
41 changes: 41 additions & 0 deletions
41
tests/netgroup/test_netgroup_ext_member_client_context.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
|
||
- name: Test netgroup with external members, client context | ||
hosts: ipaclients, ipaserver | ||
become: no | ||
gather_facts: no | ||
remote_user: root | ||
|
||
tasks: | ||
- name: Include FreeIPA facts. | ||
ansible.builtin.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. | ||
ipanetgroup: | ||
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 netgroup with external members using client context, in client host. | ||
ansible.builtin.import_playbook: test_netgroup_ext_member.yml | ||
when: groups['ipaclients'] | ||
vars: | ||
ipa_test_host: ipaclients | ||
|
||
- name: Test netgroup with external members using client context, in server host. | ||
ansible.builtin.import_playbook: test_netgroup_ext_member.yml | ||
when: groups['ipaclients'] is not defined or not groups['ipaclients'] | ||
vars: | ||
ipa_context: client |
Oops, something went wrong.