openstack-ansible-os_nova/tasks/nova_selinux.yml
Marc Gariepy b87bb37d8c Search for whole equivalence for SElinux
Change-Id: I4d5030c26c1e18af0ff44b460cb5bc65c5523036
2017-03-24 14:51:08 -04:00

42 lines
1.5 KiB
YAML

---
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Check if /var/lib/nova exists
stat:
path: /var/lib/nova
register: openstack_nova_dir
- name: Check for SELinux equivalence for /var/lib/nova
shell: "semanage fcontext -l /var/lib/nova | grep '^/var/lib/nova = /var/log/libvirt$' || true"
register: fcontext_check
tags:
- skip_ansible_lint
- name: Create SELinux fcontext equivalence for nova instance dir
command: semanage fcontext --add --equal /var/log/libvirt /var/lib/nova
failed_when: selinux_equivalence.rc not in [0,1]
changed_when: selinux_equivalence.rc == 0
register: selinux_equivalence
when:
- openstack_nova_dir.stat.exists
- '"/var/lib/nova" not in fcontext_check.stdout'
- name: Apply updated SELinux contexts on /var/lib/nova
command: restorecon -R /var/lib/nova
when:
- openstack_nova_dir.stat.exists
- '"/var/lib/nova" not in fcontext_check.stdout'
- selinux_equivalence | changed