fix: relabel Splunk install dir after unarchive, only when SELinux is enabled - #935
Open
tod-uma wants to merge 1 commit into
Open
fix: relabel Splunk install dir after unarchive, only when SELinux is enabled#935tod-uma wants to merge 1 commit into
tod-uma wants to merge 1 commit into
Conversation
… enabled unarchive extracts files with the extracting process's default SELinux context, which on an enforcing host can mismatch the context splunkd's own policy expects for $SPLUNK_HOME -- restorecon corrects that. Gated on ansible_facts.selinux.status so this is a no-op (rather than a hard failure) on any host without an SELinux userland -- restorecon doesn't exist there, e.g. Debian/Ubuntu -- and changed_when: false since relabeling doesn't represent state this playbook should ever report as "changed".
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
unarchiveextracts files with the extracting process's own default SELinux context, which on an SELinux-enforcing host can mismatch the context splunkd's policy expects under$SPLUNK_HOME—restoreconcorrects that after install.What
Adds a
restorecon -irv {{ splunk.home }}step after the unarchive task ininstall_splunk_tgz.yml, gated onansible_facts.selinux.status == 'enabled'. Without the gate this would hard-fail on any host with no SELinux userland at all (e.g. Debian/Ubuntu, where therestoreconbinary doesn't exist), rather than being a no-op there.changed_when: falsesince relabeling isn't state this playbook should report as "changed".Verified
ansible_facts.selinuxis a core-gathered fact (no extragather_subsetneeded);statusis'enabled'/'disabled'on hosts with the SELinux userland present, and the key is absent entirely on hosts without it, hence the| default('disabled')fallback.