common: kernel_modules loads kernel modules now and at boot, skipped in containers
This commit is contained in:
@@ -22,3 +22,6 @@ journald_size_cap:
|
|||||||
# Remove fail2ban from the host (only while the CrowdSec agent and bouncer run); set with
|
# Remove fail2ban from the host (only while the CrowdSec agent and bouncer run); set with
|
||||||
# -e fail2ban_remove=true once CrowdSec covers the jails of the host.
|
# -e fail2ban_remove=true once CrowdSec covers the jails of the host.
|
||||||
fail2ban_remove: false
|
fail2ban_remove: false
|
||||||
|
|
||||||
|
# Kernel modules loaded now and at boot (/etc/modules-load.d/ansible.conf). Skipped in containers.
|
||||||
|
kernel_modules: []
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# A container shares the kernel of its host, so the host loads the modules for it.
|
||||||
|
- block:
|
||||||
|
- name: Load kernel modules at boot
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/modules-load.d/ansible.conf
|
||||||
|
content: "{{ kernel_modules | join('\n') }}\n"
|
||||||
|
mode: "0644"
|
||||||
|
when: kernel_modules | length > 0
|
||||||
|
|
||||||
|
- name: Remove the boot list of kernel modules
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/modules-load.d/ansible.conf
|
||||||
|
state: absent
|
||||||
|
when: kernel_modules | length == 0
|
||||||
|
|
||||||
|
- name: Load kernel modules now
|
||||||
|
community.general.modprobe:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
loop: "{{ kernel_modules }}"
|
||||||
|
when: ansible_facts['virtualization_type'] not in ['lxc', 'docker', 'podman', 'container'] or ansible_facts['virtualization_role'] != 'guest'
|
||||||
@@ -18,3 +18,6 @@
|
|||||||
|
|
||||||
- import_tasks: ./journald.yml
|
- import_tasks: ./journald.yml
|
||||||
tags: journald
|
tags: journald
|
||||||
|
|
||||||
|
- import_tasks: ./kernel_modules.yml
|
||||||
|
tags: kernel_modules
|
||||||
|
|||||||
Reference in New Issue
Block a user