Defined Type: kmod::setting

Defined in:
manifests/setting.pp

Summary

Manage kernel module settings

Overview

Examples:

kmod__setting { 'kmod::option bond0 mode':
  ensure   => 'present',
  module   => 'bond0',
  category => 'options',
  file     => '/etc/modprobe.d/bond0.conf',
  option   => 'mode',
  value    => '1',
}

Parameters:

  • file (Stdlib::Unixpath)

    File to manage

  • category (String[1])

    Setting type

  • option (Optional[String]) (defaults to: undef)

    Key to manage

  • value (Optional[Scalar]) (defaults to: undef)

    Value to manage

  • module (String[1]) (defaults to: $name)

    Module to manage

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    State of the setting



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
# File 'manifests/setting.pp', line 19

define kmod::setting (
  Stdlib::Unixpath          $file,
  String[1]                 $category,
  Optional[String]          $option = undef,
  Optional[Scalar]          $value  = undef,
  String[1]                 $module = $name,
  Enum['present', 'absent'] $ensure = 'present',
) {
  include kmod

  ensure_resource(
    'file',
    $file,
    {
      'ensure' => 'file',
      'owner'  => $kmod::owner,
      'group'  => $kmod::group,
      'mode'   => $kmod::file_mode,
    }
  )

  case $ensure {
    'present': {
      if $option {
        $changes = [
          "set ${category}[. = '${module}'] ${module}",
          "set ${category}[. = '${module}']/${option} ${value}",
        ]
      } else {
        $changes = [
          "set ${category}[. = '${module}'] ${module}",
        ]
      }
    }

    'absent': {
      $changes = "rm ${category}[. = '${module}']"
    }

    default: { fail ( "unknown ensure value ${ensure}" ) }
  }

  augeas { "kmod::setting ${title} ${module}":
    incl    => $file,
    lens    => 'Modprobe.lns',
    changes => $changes,
    require => File[$file],
  }
}