Add selinux rules to allow lxc-attach after reboot

Lxc-attach does not work after a reboot on CentOS
it needs a selinux module to allow it.

Change-Id: I4226a86b852193a4c3c2812ea4879b37cca348e6
This commit is contained in:
Marc Gariepy 2016-11-30 10:45:38 -05:00 committed by Marc Gariépy
parent d0ed655dbe
commit 6fd1f9e0c4
3 changed files with 38 additions and 0 deletions

11
files/lxc-attach.te Normal file
View File

@ -0,0 +1,11 @@
module lxc-attach 1.0;
require {
type unconfined_service_t;
type var_lib_t;
class file entrypoint;
}
#============= unconfined_service_t ==============
allow unconfined_service_t var_lib_t:file entrypoint;

View File

@ -218,3 +218,29 @@
service:
name: lxc
enabled: "yes"
- name: Create directory for compiling SELinux rule
file:
path: "/tmp/lxc-attach-selinux/"
state: 'directory'
mode: '0755'
- name: Drop SELinux config
copy:
src: "lxc-attach.te"
dest: "/tmp/lxc-attach-selinux/lxc-attach.te"
owner: "root"
group: "root"
mode: "0755"
- name: Compile and load SELinux module
command: '{{ item }}'
args:
creates: '/etc/selinux/targeted/modules/active/modules/lxc-attach.pp'
chdir: "/tmp/lxc-attach-selinux/"
with_items:
- make -f /usr/share/selinux/devel/Makefile
- semodule -i /tmp/lxc-attach-selinux/lxc-attach.pp
when:
- ansible_selinux.status == "enabled"

View File

@ -37,6 +37,7 @@ lxc_hosts_distro_packages:
- python34-devel
- pkgconfig
- redhat-lsb
- selinux-policy-devel
- xz
lxc_xz_bin: xz