/
modules.yml
75 lines (68 loc) · 2.34 KB
/
modules.yml
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
# linux_postinstall modules
- name: "modules: Debug"
vars:
msg: |-
ansible_os_family: {{ ansible_os_family }}
lp_modules_conf: {{ lp_modules_conf }}
lp_modules:
{{ lp_modules|to_yaml(indent=2)|indent(2) }}
lp_modules_options_path: {{ lp_modules_options_path }}
lp_modules_options:
{{ lp_modules_options|to_nice_yaml(indent=2)|indent(2) }}
lp_modules_blacklist_path: {{ lp_modules_blacklist_path }}
lp_modules_blacklist:
{{ lp_modules_blacklist|to_nice_yaml(indent=2)|indent(2) }}
lp_backup_conf: {{ lp_backup_conf }}
ansible.builtin.debug:
msg: "{{ '{}'.format(msg) }}"
when: lp_modules_debug|bool
tags: lp_modules_debug
- name: "modules: modprobe modules"
community.general.modprobe:
name: "{{ item.name }}"
params: "{{ item.params }}"
state: "{{ item.state|default('present') }}"
loop: "{{ lp_modules }}"
# Debian
- name: "modules: Configure {{ lp_modules_conf }} in Debian"
ansible.builtin.lineinfile:
dest: "{{ lp_modules_conf }}"
regexp: '^\s*{{ item.name }}\s*(.*)$'
line: "{{ item.name }} {{ item.params }}"
backup: "{{ lp_backup_conf }}"
loop: "{{ lp_modules }}"
when:
- ansible_os_family == 'Debian'
- item.state|default('present') == 'present'
# RedHat
- name: "modules: Configure {{ lp_modules_conf }} in RedHat"
ansible.builtin.lineinfile:
dest: "{{ lp_modules_conf }}"
regexp: '^\s*modprobe\s+{{ item.name }}\s*(.*)$'
line: "modprobe {{ item.name }} {{ item.params }}"
backup: "{{ lp_backup_conf }}"
loop: "{{ lp_modules }}"
when:
- ansible_os_family == 'RedHat'
- item.state|default('present') == 'present'
- name: "modules: Blacklist modules in {{ lp_modules_blacklist_path }}"
ansible.builtin.template:
src: blacklist-module.j2
dest: "{{ lp_modules_blacklist_path }}/blacklist-{{ item }}.conf"
backup: "{{ lp_backup_conf }}"
mode: '0644'
loop: "{{ lp_modules_blacklist }}"
notify: update initramfs
- name: "modules: Set modules options in {{ lp_modules_options_path }}"
ansible.builtin.template:
src: options-module.j2
dest: "{{ lp_modules_options_path }}/{{ item.module }}.conf"
backup: "{{ lp_backup_conf }}"
mode: '0644'
loop: "{{ lp_modules_options }}"
loop_control:
label: "{{ item.module }}: {{ item.options }}"
notify: update initramfs
# EOF
...