Load and persist modules from the host.
This reusable ansible role will be used in tripleo-heat-templates in order to load known kernel modules such as ip_vs, iscsi and some other that are for now loaded from within the containers. Change-Id: Ic9076a0a1a8e1360495dcf0eb766118ec63dc362
This commit is contained in:

committed by
Emilien Macchi

parent
627576ab86
commit
72dbb3cb6b
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Loads and persist kernel modules from the host directly.
|
7
roles/tripleo-module-load/defaults/main.yaml
Normal file
7
roles/tripleo-module-load/defaults/main.yaml
Normal 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: []
|
52
roles/tripleo-module-load/tasks/main.yaml
Normal file
52
roles/tripleo-module-load/tasks/main.yaml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
---
|
||||||
|
# Allow to get a clean way to load and persist kernel modules
|
||||||
|
|
||||||
|
- 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: "Set modules persistence 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
|
2
roles/tripleo-module-load/templates/module-load.conf.j2
Normal file
2
roles/tripleo-module-load/templates/module-load.conf.j2
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
{{ item.name }} {{ item.params |default('') }}
|
Reference in New Issue
Block a user