forked from openstack/kayobe
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from stackhpc/selinux-state
Backport selinux change from zed
- Loading branch information
Showing
18 changed files
with
110 additions
and
91 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
9 changes: 8 additions & 1 deletion
9
...e/roles/disable-selinux/defaults/main.yml → ansible/roles/selinux/defaults/main.yml
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
--- | ||
# Target SELinux policy | ||
selinux_policy: targeted | ||
|
||
# Target SELinux state | ||
selinux_state: disabled | ||
|
||
# Whether to reboot to apply SELinux config changes. | ||
disable_selinux_do_reboot: true | ||
selinux_do_reboot: "{{ disable_selinux_do_reboot }}" | ||
|
||
# Number of seconds to wait for hosts to become accessible via SSH after being | ||
# rebooted. | ||
disable_selinux_reboot_timeout: | ||
selinux_reboot_timeout: |
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,54 @@ | ||
--- | ||
- name: Ensure required packages are installed | ||
package: | ||
name: python3-libselinux | ||
state: present | ||
cache_valid_time: "{{ apt_cache_valid_time if ansible_facts.os_family == 'Debian' else omit }}" | ||
update_cache: "{{ True if ansible_facts.os_family == 'Debian' else omit }}" | ||
become: True | ||
|
||
- name: Check if SELinux configuration file exists | ||
stat: | ||
path: /etc/selinux/config | ||
register: stat_result | ||
|
||
- name: Ensure desired SELinux state | ||
selinux: | ||
policy: "{{ selinux_policy }}" | ||
state: "{{ selinux_state }}" | ||
register: selinux_result | ||
become: True | ||
when: stat_result.stat.exists | ||
|
||
- block: | ||
- name: Abort SELinux configuration because reboot is disabled | ||
fail: | ||
msg: > | ||
SELinux state change requires a reboot, but selinux_do_reboot is | ||
false. Please run again with selinux_do_reboot set to true to reboot. | ||
when: | ||
- not selinux_do_reboot | bool | ||
|
||
- block: | ||
- name: Set a fact to determine whether we are running locally | ||
set_fact: | ||
is_local: "{{ lookup('pipe', 'hostname') in [ansible_facts.hostname, ansible_facts.nodename] }}" | ||
|
||
- name: Reboot the system to apply SELinux changes (local) | ||
command: shutdown -r now "Applying SELinux changes" | ||
become: True | ||
when: | ||
- is_local | bool | ||
|
||
- name: Reboot the machine to apply SELinux | ||
reboot: | ||
reboot_timeout: "{{ selinux_reboot_timeout }}" | ||
msg: Applying SELinux changes | ||
become: true | ||
when: | ||
- not is_local | bool | ||
when: | ||
- selinux_do_reboot | bool | ||
when: | ||
- stat_result.stat.exists | ||
- selinux_result.reboot_required |
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,9 @@ | ||
--- | ||
- name: Configure SELinux state and reboot if required | ||
hosts: seed:overcloud:infra-vms | ||
tags: | ||
- selinux | ||
roles: | ||
- role: selinux | ||
selinux_reboot_timeout: "{{ disable_selinux_reboot_timeout | default(600 if ansible_facts.virtualization_role == 'host' else 300) }}" | ||
when: ansible_facts.os_family == 'RedHat' |
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
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
17 changes: 17 additions & 0 deletions
17
releasenotes/notes/rename-disable-selinux-9053ff36792066bc.yaml
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,17 @@ | ||
--- | ||
features: | ||
- | | ||
Adds functionality to configure desired SELinux state (in addition to | ||
disabling SELinux previously). | ||
upgrade: | ||
- | | ||
The ``disable-selinux`` role has been renamed to ``selinux`` and so have | ||
been the related variables. If you set one of them, adapt your | ||
configuration: | ||
* ``disable_selinux_do_reboot`` becomes ``selinux_do_reboot`` | ||
* ``disable_selinux_reboot_timeout`` becomes ``selinux_reboot_timeout`` | ||
- | | ||
Kayobe still sets SELinux to ``disabled`` by default, unlike in the Zed | ||
13.0.0 release. Operators may want to set ``selinux_state`` to | ||
``permissive`` to avoid another reboot in the Zed upgrade. |