Add missing selinux policy package for running gunicorn

Running gunicorn out of a virtualenv in a home directory requires
some extra selinux policies.

Fixes: https://github.com/ansible-community/ara/issues/49
Change-Id: I027d148d846e7add391b28e805f67cbe312dcde0
This commit is contained in:
David Moreau Simard 2019-05-28 12:27:13 -04:00
parent 0457e8ef97
commit 9df768c413
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,10 @@
module ara-gunicorn 1.0;
require {
type admin_home_t;
type init_t;
class file { execute execute_no_trans ioctl lock open read write };
}
#============= init_t ==============
allow init_t admin_home_t:file { execute execute_no_trans ioctl lock open read write };

View File

@ -23,8 +23,27 @@
virtualenv: "{{ ara_api_venv | bool | ternary(ara_api_venv_path, omit) }}" virtualenv: "{{ ara_api_venv | bool | ternary(ara_api_venv_path, omit) }}"
virtualenv_command: /usr/bin/python3 -m venv virtualenv_command: /usr/bin/python3 -m venv
- when: ansible_os_family == "RedHat"
block:
- name: Transfer gunicorn selinux type enforcement file
copy:
src: ara-gunicorn.te
dest: "{{ ara_api_root_dir }}/ara-gunicorn.te"
# TODO: Only compile a new module and policy package when necessary
- name: Compile ara-gunicorn selinux module
command: "checkmodule -M -m -o {{ ara_api_root_dir }}/ara-gunicorn.mod {{ ara_api_root_dir }}/ara-gunicorn.te"
- name: Compile ara-gunicorn selinux policy package
command: "semodule_package -o {{ ara_api_root_dir }}/ara-gunicorn.pp -m {{ ara_api_root_dir }}/ara-gunicorn.mod"
- become: yes - become: yes
block: block:
# TODO: Only install the selinux module if it has changed
- name: Install selinux policy package
command: "semodule -i {{ ara_api_root_dir }}/ara-gunicorn.pp"
when: ansible_os_family == "RedHat"
- name: Set up systemd unit file for gunicorn to run the ARA API - name: Set up systemd unit file for gunicorn to run the ARA API
template: template:
src: ara-api.service.j2 src: ara-api.service.j2