Skip to content

fix: relabel Splunk install dir after unarchive, only when SELinux is enabled - #935

Open
tod-uma wants to merge 1 commit into
splunk:developfrom
tod-uma:fix/restorecon-selinux-gate
Open

fix: relabel Splunk install dir after unarchive, only when SELinux is enabled#935
tod-uma wants to merge 1 commit into
splunk:developfrom
tod-uma:fix/restorecon-selinux-gate

Conversation

@tod-uma

@tod-uma tod-uma commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Why

unarchive extracts 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_HOMErestorecon corrects that after install.

What

Adds a restorecon -irv {{ splunk.home }} step after the unarchive task in install_splunk_tgz.yml, gated on ansible_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 the restorecon binary doesn't exist), rather than being a no-op there. changed_when: false since relabeling isn't state this playbook should report as "changed".

Verified

ansible_facts.selinux is a core-gathered fact (no extra gather_subset needed); status is 'enabled'/'disabled' on hosts with the SELinux userland present, and the key is absent entirely on hosts without it, hence the | default('disabled') fallback.

… 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".
@tod-uma
tod-uma requested a review from a team as a code owner September 4, 2026 18:00
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.

1 participant