common: kernel_modules loads kernel modules now and at boot, skipped in containers

This commit is contained in:
2026-11-28 12:42:53 +00:00
parent 0443e20cfa
commit 4b4280ccf4
3 changed files with 27 additions and 0 deletions
+21
View File
@@ -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'
+3
View File
@@ -18,3 +18,6 @@
- import_tasks: ./journald.yml
tags: journald
- import_tasks: ./kernel_modules.yml
tags: kernel_modules