Enforce SELinux on EL and Enable Apparmor in Ubuntu/Debian/SUSE#225
Enforce SELinux on EL and Enable Apparmor in Ubuntu/Debian/SUSE#225weizhouapache wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces shared Ansible task snippets to enforce SELinux on Enterprise Linux hosts and enable/enforce AppArmor on Ubuntu/Debian/SUSE, and then wires those snippets into the MySQL, KVM, CloudStack manager, and Marvin roles (replacing prior “permissive/disable” logic).
Changes:
- Add
Ansible/tasks/configure_selinux.ymlto switch SELinux to enforcing (runtime + persistent). - Add
Ansible/tasks/configure_apparmor.ymlto install AppArmor tooling and enforce AppArmor profiles. - Replace per-role SELinux/AppArmor handling with
includecalls to the shared task files across multiple distro-specific role task files.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| Ansible/tasks/configure_selinux.yml | New shared SELinux enforcement tasks used by EL roles. |
| Ansible/tasks/configure_apparmor.yml | New shared AppArmor enable/enforce tasks used by Debian/Ubuntu/SUSE roles. |
| Ansible/roles/mysql/tasks/suse.yml | Switch SUSE MySQL role to include shared AppArmor configuration. |
| Ansible/roles/mysql/tasks/el9.yml | Switch EL9 MySQL role to include shared SELinux enforcement. |
| Ansible/roles/mysql/tasks/centos8.yml | Switch CentOS 8 MySQL role to include shared SELinux enforcement. |
| Ansible/roles/mysql/tasks/centos.yml | Switch CentOS MySQL role to include shared SELinux enforcement. |
| Ansible/roles/marvin/tasks/main.yml | Replace Marvin role SELinux permissive setup with shared SELinux enforcement include. |
| Ansible/roles/kvm/tasks/ubuntu.yml | Replace libvirt AppArmor disable steps with shared AppArmor enforcement include. |
| Ansible/roles/kvm/tasks/suse.yml | Switch SUSE KVM role to include shared AppArmor configuration. |
| Ansible/roles/kvm/tasks/el9.yml | Switch EL9 KVM role to include shared SELinux enforcement. |
| Ansible/roles/kvm/tasks/debian.yml | Replace libvirt AppArmor disable steps with shared AppArmor enforcement include. |
| Ansible/roles/kvm/tasks/centos8.yml | Switch CentOS 8 KVM role to include shared SELinux enforcement. |
| Ansible/roles/kvm/tasks/centos.yml | Switch CentOS KVM role to include shared SELinux enforcement. |
| Ansible/roles/cloudstack-manager/tasks/ubuntu.yml | Add shared AppArmor configuration include before DB setup. |
| Ansible/roles/cloudstack-manager/tasks/suse.yml | Switch SUSE mgmt role from SELinux permissive handling to shared AppArmor configuration. |
| Ansible/roles/cloudstack-manager/tasks/el9.yml | Switch EL9 mgmt role to include shared SELinux enforcement. |
| Ansible/roles/cloudstack-manager/tasks/debian.yml | Add shared AppArmor configuration include before DB setup. |
| Ansible/roles/cloudstack-manager/tasks/centos8.yml | Switch CentOS 8 mgmt role to include shared SELinux enforcement. |
| Ansible/roles/cloudstack-manager/tasks/centos.yml | Switch CentOS mgmt role to include shared SELinux enforcement. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - mysqlconf | ||
|
|
||
| - name: Set selinux to permissive | ||
| command: setenforce permissive | ||
| changed_when: false | ||
| tags: | ||
| - mysql | ||
| - mysqlconf | ||
|
|
||
| - name: Ensure selinux is set permanently | ||
| selinux: | ||
| policy: targeted | ||
| state: permissive | ||
| tags: | ||
| - mysql | ||
| - mysqlconf | ||
| - include: ../../../tasks/configure_selinux.yml | ||
|
|
| - mysqlconf | ||
|
|
||
| - name: Set selinux to permissive | ||
| command: setenforce permissive | ||
| changed_when: false | ||
| tags: | ||
| - mysql | ||
| - mysqlconf | ||
|
|
||
| - name: Ensure selinux is set permanently | ||
| selinux: | ||
| policy: targeted | ||
| state: permissive | ||
| tags: | ||
| - mysql | ||
| - mysqlconf | ||
| - include: ../../../tasks/configure_selinux.yml | ||
|
|
| ignore_errors: yes | ||
|
|
||
| - name: Set selinux to permissive | ||
| command: setenforce permissive | ||
| changed_when: false | ||
| tags: | ||
| - mysql | ||
| - mysqlconf | ||
| ignore_errors: yes | ||
|
|
||
| - name: Ensure selinux is set permanently | ||
| selinux: policy=targeted state=permissive | ||
| tags: | ||
| - kvm | ||
| ignore_errors: yes | ||
| - include: ../../../tasks/configure_apparmor.yml | ||
|
|
| - kvm | ||
|
|
||
| - name: Set selinux to permissive | ||
| command: setenforce permissive | ||
| changed_when: false | ||
| tags: | ||
| - kvm | ||
|
|
||
| - name: Ensure selinux is set permanently | ||
| selinux: policy=targeted state=permissive | ||
| tags: | ||
| - kvm | ||
| - include: ../../../tasks/configure_selinux.yml | ||
|
|
| tags: | ||
| - kvm | ||
|
|
||
| - name: Set selinux to permissive | ||
| command: setenforce permissive | ||
| changed_when: false | ||
| tags: | ||
| - kvm | ||
|
|
||
| - name: Ensure selinux is set permanently | ||
| selinux: policy=targeted state=permissive | ||
| tags: | ||
| - kvm | ||
| - include: ../../../tasks/configure_selinux.yml | ||
|
|
| shell: "zypper install -y net-tools-deprecated" | ||
| ignore_errors: yes # This package is deprecated. ignoring errors for older distros | ||
|
|
||
| - name: Set selinux to permissive | ||
| command: setenforce permissive | ||
| changed_when: false | ||
| tags: | ||
| - kvm | ||
| ignore_errors: yes | ||
|
|
||
| - name: Ensure selinux is set permanently | ||
| selinux: policy=targeted state=permissive | ||
| tags: | ||
| - kvm | ||
| ignore_errors: yes | ||
| - include: ../../../tasks/configure_apparmor.yml | ||
|
|
| - name: Install apparmor-utils | ||
| apt: | ||
| pkg: apparmor-utils | ||
| state: latest | ||
| update_cache: yes |
| - name: Get current SELinux mode | ||
| shell: getenforce || true | ||
| register: selinux_mode | ||
|
|
||
| - name: Set selinux to enforcing |
| selinux: policy=targeted state=permissive | ||
| tags: | ||
| - kvm | ||
| - include: ../../../tasks/configure_selinux.yml |
|
@wei do these copilot stuff have any sense, or do we just say "when kvm tag included" at a much higher level ("wrapper" script which when tag KVM - invokes these specific Ubuntu/EL sub tasks) ? |
@andrijapanicsb |
No description provided.