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

Conversation

justin-stephenson
Copy link
Collaborator

authselect removes with-files-domain feature in F40+/RHEL10+, it is replaced by 'with-tlog' feature because the SSSD files domain is removed entirely there. This will not be backported to RHEL9 therefore we still need to execute 'authselect select sssd with-files-domain' on RHEL9 and older Fedora versions.

@justin-stephenson
Copy link
Collaborator Author

Hi @richm Could you help me with this implementation of this PR? I imagine there is a better way than what I have proposed here. The role needs to execute 'authselect select sssd with-tlog' in F40+/RHEL10+ only.

tasks/main.yml Outdated
command: authselect select sssd with-tlog --force
when:
- not ansible_check_mode
- tlog_use_sssd
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- tlog_use_sssd
- tlog_use_sssd | bool

@richm
Copy link
Contributor

richm commented Jan 27, 2024

Hi @richm Could you help me with this implementation of this PR? I imagine there is a better way than what I have proposed here. The role needs to execute 'authselect select sssd with-tlog' in F40+/RHEL10+ only.

I think this is pretty good - I think you are using "duck typing" to see if authselect has the with-tlog feature instead of using a condition like ansible_facts["distribution_major_version"] | int >= 10.

The only thing I would suggest is to first do the

- name: Check appropriate authselect features exists
  command: authselect list-features sssd
  register: __tlog_authselect_features
  changed_when: false

then have a block which does the stuff that's only applicable when: '"with-tlog" in __tlog_authselect_features.stdout'

@justin-stephenson
Copy link
Collaborator Author

Hi @richm Could you help me with this implementation of this PR? I imagine there is a better way than what I have proposed here. The role needs to execute 'authselect select sssd with-tlog' in F40+/RHEL10+ only.

I think this is pretty good - I think you are using "duck typing" to see if authselect has the with-tlog feature instead of using a condition like ansible_facts["distribution_major_version"] | int >= 10.

The only thing I would suggest is to first do the

- name: Check appropriate authselect features exists
  command: authselect list-features sssd
  register: __tlog_authselect_features
  changed_when: false

then have a block which does the stuff that's only applicable when: '"with-tlog" in __tlog_authselect_features.stdout'

Thank you, please check the updated version.

@justin-stephenson
Copy link
Collaborator Author

@jakub-vavra-cz For your information.

tasks/main.yml Outdated
- 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
failed_when: __tlog_authselect_current.rc not in [0, 2]

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

extra blank line

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.

@@ -0,0 +1,28 @@
---
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

that:
- __nsswitch_contents | regex_search('^passwd:\\s+sss', multiline=True)
- '"with-tlog" in __tlog_authselect_current.stdout'
when:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
when:
when: '"with-tlog" in __tlog_authselect_features.stdout'

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.

- __nsswitch_contents | regex_search('^passwd:\\s+sss', multiline=True)
- '"with-tlog" in __tlog_authselect_current.stdout'
when:
- '"with-tlog" in __tlog_authselect_features.stdout'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- '"with-tlog" in __tlog_authselect_features.stdout'

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.

set_fact:
__nsswitch_contents: "{{ __nsswitch_slurp['content'] | b64decode }}"

- name: Check if files domain enabled and nsswitch set correctly
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be an opposite check for systems where "with-tlog" not in __tlog_authselect_features.stdout?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If with-tlog feature is not available then we fallback to with-files-domain feature, which we already have a test for tests/check_sssd_files_provider.yml

@justin-stephenson justin-stephenson force-pushed the authselect_with_tlog branch 3 times, most recently from c73d8de to 9003a4e Compare January 30, 2024 14:30
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'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
when: - '"with-tlog" in __tlog_authselect_features.stdout'
when: '"with-tlog" in __tlog_authselect_features.stdout'

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.

tasks/main.yml Outdated
command: authselect current
register: __tlog_authselect_current
changed_when: false
failed_when: __tlog_authselect_current.rc not in [0, 2]
notify: Handler tlog_handler restart sssd
changed_when: true
Copy link
Contributor

Choose a reason for hiding this comment

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

You have both changed_when: false and changed_when: true - if this command doesn't change anything, you should have changed_when: false and no notify

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.

tasks/main.yml Show resolved Hide resolved
src: /etc/nsswitch.conf
register: __nsswitch_slurp

- name: Decode nsswitch content
Copy link
Contributor

Choose a reason for hiding this comment

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

since you are using vars below, you can get rid of this task

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.

@richm
Copy link
Contributor

richm commented Jan 30, 2024

@justin-stephenson how should we document this change? Is this something users should know about, or is just something that the role takes care of for the user that the user doesn't have to know about? This doesn't seem like a bug fix or a new feature - could it be considered a refactoring?

authselect removes with-files-domain feature in F40+/RHEL10+,
it is replace with the 'with-tlog' feature.
@justin-stephenson
Copy link
Collaborator Author

@justin-stephenson how should we document this change? Is this something users should know about, or is just something that the role takes care of for the user that the user doesn't have to know about? This doesn't seem like a bug fix or a new feature - could it be considered a refactoring?

It might be worthwhile to mention this change briefly, but I don't think it is important to users of this role to know about. It is mostly changing internals here(how session recording is configured to work with SSSD + tlog).

@richm richm changed the title Support with-tlog authselect feature refactor: Support with-tlog authselect feature Jan 30, 2024
@richm
Copy link
Contributor

richm commented Jan 30, 2024

[citest]

@richm richm merged commit 7ef1794 into linux-system-roles:main Jan 31, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants