Puppet Class: psick::puppet::pe_agent

Defined in:
manifests/puppet/pe_agent.pp

Overview

This class manages tp::test for PE Agents

Parameters:

  • test_enable (Boolean) (defaults to: false)
  • manage_environment (Boolean) (defaults to: false)
  • environment_setting (String) (defaults to: $environment)
  • manage_noop (Boolean) (defaults to: false)
  • noop_setting (Boolean) (defaults to: false)
  • manage_service (Boolean) (defaults to: false)
  • service_ensure (Enum['running','stopped']) (defaults to: 'running')
  • service_enable (Boolean) (defaults to: true)
  • manage_exclude_unchanged_resources (Boolean) (defaults to: false)
  • exclude_unchanged_resources_setting (Boolean) (defaults to: true)
  • settings (Hash) (defaults to: {})
  • ini_settings_hash (Hash) (defaults to: {})
  • config_file_path (String) (defaults to: '/etc/puppetlabs/puppet/puppet.conf')
  • manage (Boolean) (defaults to: $psick::manage)
  • noop_manage (Boolean) (defaults to: $psick::noop_manage)
  • noop_value (Boolean) (defaults to: $psick::noop_value)


3
4
5
6
7
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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'manifests/puppet/pe_agent.pp', line 3

class psick::puppet::pe_agent (
  Boolean $test_enable        = false,

  Boolean $manage_environment = false,
  String $environment_setting = $environment,

  Boolean $manage_noop        = false,
  Boolean $noop_setting       = false,

  Boolean $manage_service     = false,
  Enum['running','stopped'] $service_ensure = 'running',
  Boolean $service_enable     = true,

  Boolean $manage_exclude_unchanged_resources  = false,
  Boolean $exclude_unchanged_resources_setting = true,

  Hash $settings              = {},
  Hash $ini_settings_hash     = {},
  String $config_file_path    = '/etc/puppetlabs/puppet/puppet.conf',

  Boolean $manage             = $psick::manage,
  Boolean $noop_manage        = $psick::noop_manage,
  Boolean $noop_value         = $psick::noop_value,
) {
  if $manage {
    if $noop_manage {
      noop($noop_value)
    }

    if $test_enable {
      Tp::Test {
        cli_enable => true,
      }
      tp::test { 'puppet-agent': settings_hash => $settings }
    }

    # Manage Puppet agent service
    if $manage_service {
      service { 'puppet':
        ensure => $service_ensure,
        enable => $service_enable,
      }
      $service_notify = 'Service[puppet]'
    } else {
      $service_notify = undef
    }

    # Set environment
    if $manage_environment {
      pe_ini_setting { 'agent conf file environment':
        ensure  => present,
        path    => $config_file_path,
        section => 'agent',
        setting => 'environment',
        value   => $environment_setting,
        notify  => $service_notify,
      }
    }

    # Set noop mode
    if $manage_noop {
      pe_ini_setting { 'agent conf file noop':
        ensure  => present,
        path    => $config_file_path,
        section => 'agent',
        setting => 'noop',
        value   => $noop_setting,
        notify  => $service_notify,
      }
    }

    # Set exclude_unchanged_resources
    if $manage_exclude_unchanged_resources {
      pe_ini_setting { 'agent conf file exclude_unchanged_resources':
        ensure  => present,
        path    => $config_file_path,
        section => 'main',
        setting => 'exclude_unchanged_resources',
        value   => $exclude_unchanged_resources_setting,
        notify  => $service_notify,
      }
    }

    $default_ini_settings = {
      ensure  => present,
      path    => $config_file_path,
      notify  => $service_notify,
    }
    $ini_settings_hash.each | $k,$v | {
      $k.each | $kk,$vv | {
        $ini_settings = {
          section => $k,
          setting => $kk,
          value   => $vv,
        }
        pe_ini_setting { "puppet.conf ${k} - ${kk}":
          * => $default_ini_settings + $ini_settings,
        }
      }
    }
  }
}