Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Add become to selinux handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg committed Oct 23, 2020
1 parent bcde7e3 commit be9c93e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES/7736.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added become and proper condition to SELinux handlers.
This fixes an issue with installations that are not run as root.
7 changes: 7 additions & 0 deletions roles/pulp_common/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
- name: Load the SELinux policy packages
command: 'semodule -i /usr/local/share/selinux/{{ ansible_facts.selinux.type }}/{{ item }}.pp'
loop: '{{ __pulp_selinux_policy_pkgs }}'
become: true

# Note: we cannot flush handlers until after these are created later on in the
# Pulp role, after the SELinux policies are installed.
# Installing them earlier should mean the files are created with the context to
# begin with.
- name: Restore SELinux contexts on Pulp dirs that must exist
command: '/sbin/fixfiles restore {{ __pulp_selinux_label_dirs | join(" ") }}'
become: true
# We need the when condition on this particular SELinux handler because it
# gets triggered by "Collect static content".
when:
- ansible_facts.os_family == 'RedHat'
# when permissive or enforcing. That would be stored in .mode & .config_mode
- ansible_facts.selinux.status == "enabled"

# shell for handling '*' in the dir name
- name: Restore SELinux contexts on Pulp dirs that may exist
shell: '/sbin/fixfiles restore {{ __pulp_selinux_label_dirs_optional | join(" ") }}' # noqa 305
become: true
register: result
changed_when: result.rc == 0
failed_when: result.rc not in [0,255]
Expand All @@ -43,6 +49,7 @@

- name: Restore SELinux contexts on Pulp asset dirs
command: '/sbin/fixfiles restore {{ pulp_user_home }}/assets'
become: true
# We need the when condition on this particular SELinux handler because it
# gets triggered by "Collect static content".
when:
Expand Down

0 comments on commit be9c93e

Please sign in to comment.