Defined Type: sysctl::variable

Defined in:
manifests/variable.pp

Summary

manage a kernel variable with sysctl

Overview

Parameters:

  • variable (Optional[String]) (defaults to: $title)

    kernel variable to manage, defaults to the resource title

  • ensure (Variant[String,Integer,Undef]) (defaults to: undef)

    value to assign, use absent or undef to remove

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

    prefix to conf.d variable filename

  • suffix (String) (defaults to: '.conf')

    suffix to conf.d variable filename

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

    set value from content instead of ensure _not supported if use_dir is disabled_

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

    set value from a source instead of ensure _not supported if use_dir is disabled_

  • enforce (Boolean) (defaults to: true)

    ensure value is set at puppet runtime

  • comment (Optional[Variant[String,Array[String]]]) (defaults to: undef)

    comment to add to file



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

define sysctl::variable (
  Optional[String]              $variable = $title,
  Variant[String,Integer,Undef] $ensure   = undef,
  Optional[String]              $prefix   = undef,
  String                        $suffix   = '.conf',
  Optional[String]              $content  = undef,
  Optional[String]              $source   = undef,
  Boolean                       $enforce  = true,
  Optional[Variant[String,Array[String]]] $comment = undef,
) {
  if $enforce and ($content or $source) {
    fail('enforce not supported with content or source parameters')
  }
  if ($content or $source) and !$sysctl::use_dir {
    fail('content or source not supported if use_dir is disabled')
  }
  if (($content or $source) and ($ensure !~ Undef and $ensure != 'absent')) or ($content and $source) {
    fail('inconclusive parameters, set either content, source or ensure')
  }

  $params = {
    ensure          => ($ensure =~ Integer) ? {
      true  => String($ensure),
      false => $ensure,
    },
    prefix          => $prefix,
    suffix          => $suffix,
    comment         => $comment,
    content         => $content,
    source          => $source,
    enforce         => $enforce,
  }.filter |$key,$value| { $value != undef }

  if ! defined(Sysctl::Define[$variable]) {
    @sysctl::define { $variable:
      * => $params,
    }
  } else {
    Sysctl::Define <| title == $variable |> {
      * => $params,
    }
  }
}