Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Support with-tlog authselect feature #120

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,20 @@
when: tlog_use_sssd
notify: Handler tlog_handler restart sssd

- name: Check with-files-domain feature exists
- name: Check appropriate authselect features exists
command: authselect list-features sssd
register: __tlog_authselect_features
changed_when: false

- name: Check if files domain is currently enabled
- name: Enable authselect profile with tlog feature
command: authselect select sssd with-tlog --force
justin-stephenson marked this conversation as resolved.
Show resolved Hide resolved
changed_when: true
when:
- not ansible_check_mode
- tlog_use_sssd | bool
- '"with-tlog" in __tlog_authselect_features.stdout'

- name: Check which authselect features are currently enabled
command: authselect current
register: __tlog_authselect_current
changed_when: false
Expand Down
25 changes: 25 additions & 0 deletions tests/check_sssd_with_tlog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test should be a playbook, and you have a list of tasks. Check https://github.com/linux-system-roles/tlog/blob/main/tests/tests_cockpit.yml

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

@richm richm Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test playbook filenames must match named tests_*.yml
I thought perhaps that check_sssd_with_tlog.yml was going to be a task file called from other playbooks because it does not call the tlog role, and you just had not yet changed the other test playbooks to use check_sssd_with_tlog.yml

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh okay, I see now. I fixed it so that check_sssd_with_tlog is called from tests/tests_sssd.yml

- name: Check with-tlog feature exists
command: authselect list-features sssd
register: __tlog_authselect_features
changed_when: false

- name: Check if with-tlog authselect feature is currently enabled
command: authselect current
register: __tlog_authselect_current
changed_when: false
failed_when: __tlog_authselect_current.rc not in [0, 2]

- name: Read nsswitch.conf
slurp:
src: /etc/nsswitch.conf
register: __nsswitch_slurp

- name: Check if with tlog authselect feature enabled and nsswitch set correctly
assert:
that:
- __nsswitch_contents | regex_search('^passwd:\\s+sss', multiline=True)
- '"with-tlog" in __tlog_authselect_current.stdout'
when: '"with-tlog" in __tlog_authselect_features.stdout'
justin-stephenson marked this conversation as resolved.
Show resolved Hide resolved
vars:
__nsswitch_contents: "{{ __nsswitch_slurp['content'] | b64decode }}"
8 changes: 7 additions & 1 deletion tests/tests_sssd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
vars:
tlog_scope_sssd: all

- name: Check sssd files provider setup properly
- name: Check sssd authselect with tlog setup properly
import_tasks: check_sssd_with_tlog.yml

- name: Run sssd tests
import_tasks: run_sssd_tests.yml

- name: Check authselect files provider setup properly
import_tasks: check_sssd_files_provider.yml

- name: Run sssd tests
Expand Down
Loading