Defined Type: jenkins::augeas

Defined in:
manifests/augeas.pp

Summary

Change config files using augeas

Overview

Examples:

Configure the git plugin

jenkins::augeas { 'git':
  plugin          => true,
  config_filename => 'hudson.plugins.git.GitSCM.xml',
  context         => '/hudson.plugins.git.GitSCM_-DescriptorImpl',
  changes         => [
    'set globalConfigName/#text "Bob the Builder"',
    'set globalConfigEmail/#text "bob@example.com",
  ],
}

Parameters:

  • config_filename (String)

    Filename of the configuration file to work on relative to the jenkins localstatedir.

  • changes (Variant[Array[String], String])

    String or array with augeas changes to perform.

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

    Optional augeas command and comparisons to control the execution of this type.

  • plugin (Variant[Boolean,String]) (defaults to: false)

    Optionally jenkins::augeas can also install the plugin. If this is set to true, we use the name of the resource as plugin name. If it’s a string, that is used as plugin name.

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

    Optional plugin version to pass through to jenkins::plugin

  • context (String) (defaults to: '/')

    Optional context to ease your change rules.

  • restart (Boolean) (defaults to: false)

    If set to true, will trigger a jenkins (safe-)restart in stead of reloading the configuration.

  • show_diff (Boolean) (defaults to: true)

    Whether to display differences when the file changes, defaulting to true.



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
76
77
78
79
80
81
82
83
84
85
86
87
# File 'manifests/augeas.pp', line 41

define jenkins::augeas (
  String $config_filename,
  Variant[Array[String], String] $changes,
  Optional[Variant[Array[String], String]] $onlyif = undef,
  Optional[String] $plugin_version                 = undef,
  String $context                                  = '/',
  Variant[Boolean,String] $plugin                  = false,
  Boolean $restart                                 = false,
  Boolean $show_diff                               = true,
) {
  include jenkins
  include jenkins::cli

  case $plugin {
    true: {
      jenkins::plugin { $name:
        version => $plugin_version,
        before  => Augeas["jenkins::augeas: ${name}"],
      }
    }
    false: {
      # do nothing
    }
    default: {
      jenkins::plugin { $plugin:
        version => $plugin_version,
        before  => Augeas["jenkins::augeas: ${name}"],
      }
    }
  }

  if $restart {
    $notify_exec = 'safe-restart-jenkins'
  } else {
    $notify_exec = 'reload-jenkins'
  }

  augeas { "jenkins::augeas: ${name}":
    incl      => "${jenkins::localstatedir}/${config_filename}",
    lens      => 'Xml.lns',
    context   => regsubst("/files${jenkins::localstatedir}/${config_filename}/${context}", '\/{2,}', '/', 'G'),
    notify    => Exec[$notify_exec],
    onlyif    => $onlyif,
    changes   => $changes,
    show_diff => $show_diff,
  }
}