Skip to content

Conversation

@tomasfratrik
Copy link
Collaborator

For now this is just a draft, Im not sure if we want PR for each module, or all modules in 1 PR.

Part of:
Jira: RHEL-120542

.ansible-lint Outdated
- community.general.yum_versionlock
- community.general.rhsm_repository
- ansible.posix.selinux
- redhat.rhel_system_roles.selinux
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- redhat.rhel_system_roles.selinux

We cannot use the module. We must use the role.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For selinux yes, we should use the role to ensure that selinux is properly configured. I guess it makes sense to use fedora.linux_system_roles.selinux role in the upstream. We will change this in RPM spec for downstream.

How about ansible.posix.mount? Downstream, is it a good idea to use redhat.rhel_system_roles.mount to avoid re-vendoring it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For selinux yes, we should use the role to ensure that selinux is properly configured. I guess it makes sense to use fedora.linux_system_roles.selinux role in the upstream. We will change this in RPM spec for downstream.

How about ansible.posix.mount? Downstream, is it a good idea to use redhat.rhel_system_roles.mount to avoid re-vendoring it?

That one will be problematic. Yes, there is a fedora.linux_system_roles.mount module used internally by a couple of roles - but this is only meant to be used internally by the role, not by code outside of the role. We do not want to support using modules, even if it is for "friendly" external code.

Maybe there is a way we can use the storage role, not sure.

@tomasfratrik tomasfratrik force-pushed the use-rhel-selinux-module branch from d28a4ff to 103f747 Compare December 8, 2025 15:27
@tomasfratrik tomasfratrik marked this pull request as ready for review December 8, 2025 15:27
@tomasfratrik tomasfratrik changed the title [DRAFT] Replace SELinux community module with Red Hat provided module. Replace SELinux community module with LSR Dec 8, 2025
@richm
Copy link
Collaborator

richm commented Dec 8, 2025

lgtm - you will need a changelog fragment

@tomasfratrik tomasfratrik force-pushed the use-rhel-selinux-module branch from 103f747 to ba40f1f Compare December 8, 2025 16:02
@tomasfratrik
Copy link
Collaborator Author

lgtm - you will need a changelog fragment

Added, but I am not sure about conventions here

@richm
Copy link
Collaborator

richm commented Dec 8, 2025

[citest]

reboot_timeout: "{{ reboot_timeout }}"
post_reboot_delay: "{{ post_reboot_delay }}"
timeout: "{{ reboot_timeout }}"
when: selinux_results.reboot_required
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does selinux role return a reboot_required variable? That might not be applicable to the role.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes you are right, according the documentation it should be selinux_reboot_required

selinux_state: "{{ selinux_mode }}"
check_mode: true
register: selinux_check_results
failed_when: selinux_check_results.changed
Copy link
Collaborator

Choose a reason for hiding this comment

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

include_role might not return changed variable

Copy link
Collaborator

Choose a reason for hiding this comment

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

Correct. It does not return changed

Copy link
Collaborator

Choose a reason for hiding this comment

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

in fact - you cannot use check_mode, register, or failed_when with include_role

vars:
selinux_policy: targeted
selinux_state: "{{ selinux_mode }}"
register: selinux_results
Copy link
Collaborator

Choose a reason for hiding this comment

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

register does not work with include_role

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes I have now realised that now its for include_role

@richm
Copy link
Collaborator

richm commented Dec 9, 2025

This example explains how to use the selinux role when there is the possibility that the system needs to be rebooted to apply the changes: https://github.com/linux-system-roles/selinux/blob/main/examples/selinux-playbook.yml

  • define the selinux policy you need in a vars
  • run the role in a block with a rescue
  • in the rescue section, check if the role failed for a reason other than reboot required and fail if reboot not required
  • do the reboot if reboot required
  • wait for the connection
  • run the role again to ensure the settings are applied

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