Load known, standard kernel modules from the host, not within containers

Known kernel modules are:
- dm-multipath (for multipathd)
- ip_vs (for keepalived)
- iscsi_tcp (for ironic-conductor)
- openvswitch (for openvswitch-vswitchd)

Change-Id: I1841ec30cde142c8019830ad3190847dfe493eb9
This commit is contained in:
Cédric Jeanneret 2018-09-27 11:05:08 +02:00
parent 8045b3fbd0
commit 778dba94a4
8 changed files with 98 additions and 0 deletions

View File

@ -65,6 +65,13 @@
notify:
- Restart haproxy container
- name: Load and persist keepalived module
import_role:
role: module-load
vars:
modules:
- {'name': ip_vs }
- name: Copying over keepalived.conf
vars:
service: "{{ haproxy_services['keepalived'] }}"

View File

@ -1,4 +1,11 @@
---
- name: Load and persist iscsi_tcp module
import_role:
role: module-load
vars:
modules:
- {'name': iscsi_tcp}
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item.key }}"

View File

@ -0,0 +1,7 @@
---
# Module name as a list of hashes:
# modules:
# - { name: foo, params: 'bar baz' }
# - { name: starwars }
# - { name: starwars, state: absent }
modules: []

View File

@ -0,0 +1,56 @@
---
# Allow to get a clean way to load and persist kernel modules
- name: Run tasks only for specific kolla_action
when:
- kolla_action != "config"
block:
- name: Check whether /etc/modules-load.d exists
stat:
path: /etc/modules-load.d
register: modules_load_stat
- name: "Load modules"
become: true
modprobe:
name: "{{ item.name }}"
params: "{{ item.params | default(omit) }}"
state: "{{ item.state | default('present') }}"
loop: "{{ modules }}"
loop_control:
label: "{{ item.name }}"
- name: "Persist modules via modules-load.d"
become: true
template:
dest: "/etc/modules-load.d/{{ item.name }}.conf"
src: module-load.conf.j2
loop: "{{ modules }}"
loop_control:
label: "{{ item.name }}"
when:
- modules_load_stat.stat.exists
- (item.state | default('present')) == 'present'
- name: "Drop module persistence"
become: true
file:
path: "/etc/modules-load.d/{{ item.name }}.conf"
state: absent
loop: "{{ modules }}"
loop_control:
label: "{{ item.name }}"
when:
- modules_load_stat.stat.exists
- (item.state | default('present')) == 'absent'
- name: "Persist modules via /etc/modules"
become: true
lineinfile:
dest: /etc/modules
line: "{{ item.name }} {{ item.params | default('') }}"
state: "{{ item.state | default('present') }}"
loop: "{{ modules }}"
loop_control:
label: "{{ item.name }}"
when: not modules_load_stat.stat.exists

View File

@ -0,0 +1,2 @@
# {{ ansible_managed }}
{{ item.name }} {{ item.params |default('') }}

View File

@ -1,4 +1,11 @@
---
- name: Load and persist dm-multipath module
import_role:
role: module-load
vars:
modules:
- {'name': dm-multipath}
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"

View File

@ -1,4 +1,11 @@
---
- name: Load and persist openvswitch module
import_role:
role: module-load
vars:
modules:
- {'name': openvswitch}
- name: Ensuring config directories exist
become: true
file:

View File

@ -0,0 +1,5 @@
---
features:
- Adds support for loading kernel modules required by containers. This is
required since kolla images are removing support for loading kernel modules
from within the container.