aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/module-load/tasks/main.yml
blob: 3037f87f3df064b958b16757a8c718e8695de337 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
# 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: 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:
        src: module-load.conf.j2
        dest: "/etc/modules-load.d/{{ item.name }}.conf"
      loop: "{{ modules }}"
      loop_control:
        label: "{{ item.name }}"
      when:
        - (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:
        - (item.state | default('present')) == 'absent'