-
Notifications
You must be signed in to change notification settings - Fork 231
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. Problem statement: ``` - name: Ensure sudorule is present with users and hosts (action member) ipasudorule: name: testrule2 user: - external-user action: member - name: Ensure sudorule is present with users and hosts (action member) again ipasudorule: name: testrule2 user: - external-user action: member ``` After execution of the first task with external users ansible returns changed as expected, after second it still returns changed - it's a bug. This PR fixes it. After the second task ansible will return ok. "External" entities are: for `ipasudorule`: `externalhost, externaluser, ipasudorunasextuser, ipasudorunasextgroup` for `ipanetgroup`: `externalhost` Signed-off-by: Denis Karpelevich <[email protected]>
- Loading branch information
Showing
7 changed files
with
464 additions
and
34 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
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,131 @@ | ||
--- | ||
|
||
- name: Test netgroup with external members | ||
hosts: "{{ ipa_test_host | default('ipaserver') }}" | ||
become: true | ||
gather_facts: true | ||
|
||
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 |
Oops, something went wrong.