-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use the ini_file module to test sssd.conf
The `ini` lookup is problematic with ansible 2.9 due to the arguments being completely different, and because ansible attempts to evaluate `{{ lookup('ini', ...) }}` even if guarded by a `when`, any use of the new style 2.x `ini` arguments will fail. Instead, just use the `ini_file` module itself, and rely on the fact that it will report `changed: true` if the values are different. Use `community.general.ini_file` instead of `ini_file` everywhere for consistency. Refactor the `tests_dyndns.yml` test so that it works in CI with a single host - in that case, just check that the sssd.conf was written correctly. Rename tests_sssd_custom_setttings.yml to tests_sssd_custom_settings.yml Use the new `ad_integration_sssd_custom_settings` in tests instead of writing to sssd.conf directly with `ini_file` The `tests_dyndns.yml` test wasn't working properly - in order for any parameters to be set, you must specify `ad_dyndns_update: true` Use non-FQCN `win_command` in a couple of places that Ansible 2.9 was giving an error about. Signed-off-by: Rich Megginson <[email protected]>
- Loading branch information
Showing
6 changed files
with
162 additions
and
207 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,72 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
|
||
- name: Ensure that the role configures dynamic dns | ||
hosts: all,!ad | ||
gather_facts: false # test that role works in this case | ||
vars: | ||
ad_integration_realm: sample-realm.com | ||
__ad_integration_test_sssd_config_only: true | ||
ad_integration_sssd_custom_settings: | ||
- key: auth_provider_test | ||
value: ad | ||
- key: override_shell_test | ||
value: /bin/bash | ||
|
||
tasks: | ||
- name: Test - Run the system role with bogus vars | ||
include_role: | ||
name: linux-system-roles.ad_integration | ||
|
||
- name: Check custom SSSD settings | ||
community.general.ini_file: | ||
path: /etc/sssd/sssd.conf | ||
state: "{{ item.state | default('present') }}" | ||
section: domain/{{ ad_integration_realm | lower }} | ||
option: "{{ item.key }}" | ||
value: "{{ item.value }}" | ||
create: true | ||
owner: root | ||
group: root | ||
mode: u=rw,g=,o= | ||
loop: "{{ ad_integration_sssd_custom_settings }}" | ||
register: __result | ||
failed_when: __result is changed | ||
|
||
- name: Search /var/log/sssd/sssd.log for [sss_ini_call_validators] | ||
command: >- | ||
grep -i sss_ini_call_validators /var/log/sssd/sssd.log | ||
register: sssd_log | ||
changed_when: false | ||
failed_when: false | ||
|
||
- name: Fail if signature found | ||
fail: | ||
msg: Appears to be an unsupported option in /etc/sssd/sssd.conf | ||
when: sssd_log.stdout | length > 0 | ||
|
||
- name: Test - Re-Build a list of settings with state=absent | ||
set_fact: | ||
update_list: "{{ ad_integration_sssd_custom_settings | | ||
map('combine', {'state': 'absent'}) | list }}" | ||
|
||
- name: Test - Re-run the system role to remove vars | ||
include_role: | ||
name: linux-system-roles.ad_integration | ||
vars: | ||
ad_integration_sssd_custom_settings: "{{ update_list }}" | ||
|
||
- name: Check custom SSSD settings | ||
community.general.ini_file: | ||
path: /etc/sssd/sssd.conf | ||
state: "{{ item.state | default('present') }}" | ||
section: domain/{{ ad_integration_realm | lower }} | ||
option: "{{ item.key }}" | ||
value: "{{ item.value }}" | ||
create: true | ||
owner: root | ||
group: root | ||
mode: u=rw,g=,o= | ||
loop: "{{ update_list }}" | ||
register: __result | ||
failed_when: __result is changed |
Oops, something went wrong.