Puppet Class: psick::jenkins::jcasc

Defined in:
manifests/jenkins/jcasc.pp

Summary

Installs and configures Jenkins Configuration as Code plugin

Overview

Parameters:

  • ensure (Variant[Boolean,String]) (defaults to: 'present')

    If the enable or not the plugin

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

    Template to use for jenkins.yaml file

  • options_hash (Hash) (defaults to: {})

    Customn has of options to use for jenkins.yaml

  • service_reload_command

    Command to execute to trigger Jenkins reload

  • plugins (Array) (defaults to: [ 'configuration-as-code','configuration-as-code-support' ])
  • config_path (Optional[String]) (defaults to: undef)
  • jenkins_reload_command (String) (defaults to: 'service jenkins force-reload')
  • manage (Boolean) (defaults to: $::psick::manage)
  • noop_manage (Boolean) (defaults to: $::psick::noop_manage)
  • noop_value (Boolean) (defaults to: $::psick::noop_value)


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
# File 'manifests/jenkins/jcasc.pp', line 8

class psick::jenkins::jcasc (
  Variant[Boolean,String] $ensure   = 'present',
  Array $plugins                    = [ 'configuration-as-code','configuration-as-code-support' ],
  Optional[String] $config_template = undef,
  Optional[String] $config_path     = undef,
  Hash $options_hash                = {},
  String $jenkins_reload_command    = 'service jenkins force-reload',
  Boolean $manage                   = $::psick::manage,
  Boolean $noop_manage              = $::psick::noop_manage,
  Boolean $noop_value               = $::psick::noop_value,
) {
  if $manage {
    if $noop_manage {
      noop($noop_value)
    }

    $plugin_enable = $ensure ? {
      'absent' => false,
      default  => true,
    }
    $plugins.each | $plugin | {
      if !defined(Psick::Jenkins::Plugin[$plugin]) {
        psick::jenkins::plugin { $plugin:
          enable   => $plugin_enable,
        }
      }
    }
    $real_config_path = pick($config_path,"${::psick::jenkins::home_dir}/jenkins.yaml")
    $options = $options_hash
    if $config_template {
      file { $real_config_path :
        ensure  => $ensure,
        mode    => '0644',
        owner   => 'jenkins',
        group   => 'jenkins',
        notify  => Service['jenkins'],
        replace => false,
        content => template($config_template),
        require => Package['jenkins'],
      }
    }
  }
}