Skip to content

Commit 17d1137

Browse files
committed
Ubuntu: Install apparmor package for apparmor_parser
In some cases AppArmor may be enabled, but the apparmor package that provides apparmor_parser is not installed.
1 parent 83f6590 commit 17d1137

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

tasks/install-daemon.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
- name: Ensure libvirt packages are installed
1616
package:
17-
name: "{{ libvirt_host_libvirt_packages }}"
17+
name: "{{ libvirt_host_libvirt_packages | select | list }}"
1818
state: present
1919
register: result
2020
until: result is success

tasks/post-install-Debian.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
line: " {{ item.path }}/** rwk,"
3434
become: true
3535
when:
36-
- item.type == "dir"
3736
- libvirt_host_install_daemon | bool
37+
- ansible_apparmor.status | default == 'enabled'
38+
- item.type == "dir"
3839
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
3940
notify:
4041
- reload libvirt qemu apparmor profile template

vars/Debian.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
libvirt_host_libvirt_packages_common:
44
- qemu-kvm
55

6-
# Package that contains the libvirt daemon
7-
libvirt_host_libvirt_packages_libvirt_daemon: >-
8-
{%- if (ansible_distribution == "Ubuntu" and
9-
ansible_distribution_major_version is version_compare('16.04', '<')) or
10-
(ansible_distribution == "Debian" and
11-
ansible_distribution_major_version is version_compare('8', '<')) -%}
12-
libvirt-bin
13-
{%- else -%}
14-
libvirt-daemon-system
15-
{%- endif -%}
6+
# List of all daemon packages to install.
7+
libvirt_host_libvirt_packages_libvirt_daemon:
8+
# The apparmor package contains the apparmor_parser tool.
9+
- "{% if ansible_apparmor.status| default == 'enabled' %}apparmor{% endif %}"
10+
- >-
11+
{%- if (ansible_distribution == "Ubuntu" and
12+
ansible_distribution_major_version is version_compare('16.04', '<')) or
13+
(ansible_distribution == "Debian" and
14+
ansible_distribution_major_version is version_compare('8', '<')) -%}
15+
libvirt-bin
16+
{%- else -%}
17+
libvirt-daemon-system
18+
{%- endif -%}
1619
1720
# List of all client packages to install.
1821
libvirt_host_libvirt_packages_client:
@@ -27,7 +30,7 @@ libvirt_host_packages_efi:
2730
# List of all packages to install
2831
libvirt_host_libvirt_packages: >
2932
{{ libvirt_host_libvirt_packages_common +
30-
[libvirt_host_libvirt_packages_libvirt_daemon] +
33+
libvirt_host_libvirt_packages_libvirt_daemon +
3134
libvirt_host_libvirt_packages_client +
3235
(libvirt_host_packages_efi if libvirt_host_enable_efi_support else []) | unique
3336
}}

0 commit comments

Comments
 (0)