Defined Type: kmod::module

Defined in:
modules/kmod/manifests/module.pp

Overview

Define: kmod::module

Make sure that the given kernel module is loaded (or not).

Parameters

ensure

If 'present', the module will be loaded. If 'absent', unloaded. The default is 'present'.

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: present)


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
# File 'modules/kmod/manifests/module.pp', line 11

define kmod::module(
    Wmflib::Ensure $ensure = present
) {
    $modprobe_cmd = $ensure ? {
        'present' => "/sbin/modprobe ${name}",
        'absent' => "/sbin/modprobe -r ${name}",
    }

    file { "/etc/modules-load.d/${name}.conf":
        ensure  => $ensure,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => "${name}\n",
        notify  => Exec[$modprobe_cmd],
    }

    if $ensure == 'present' {
        exec { $modprobe_cmd:
            unless      => "/bin/lsmod | /bin/grep -q '^${name} '",
            refreshonly => true,
        }
    } else {
        exec { $modprobe_cmd:
            onlyif      => "/bin/lsmod | /bin/grep -q '^${name} '",
            refreshonly => true,
        }
    }
}