Puppet Class: psick

Defined in:
manifests/init.pp

Overview

The main psick class. From here the whole infrastructure can be built. This class exposes parameters that serve as entry points to set general settings used by other psick profiles. When included, this class does nothing by default, but it’s required to be able to use PSICK for classification and/or to use any PSICK profile.

Examples:

Sample data for proxy server hash

psick::servers:
  proxy:
    host: proxy.example.com
    port: 3128
    user: john    # Optional
    password: xxx # Optional
    no_proxy:
      - localhost
      - "%{::domain}"
    scheme: http

Define arbitrary resources, with some defaults

psick::resources:
  file:
    /usr/local/bin/eyaml:
      target: /opt/puppetlabs/puppet/bin/eyaml
  package:
    zsh: {}
    ksh: {}
    nrpe:
      ensure: absent
  psick::users::managed:
    test:
      ensure: present
psick::resources_defaults:
  package:
    ensure: present
  psick::users::managed:
    shell: /bin/bash

Parameters:

  • manage (Boolean) (defaults to: true)

    If to actually manage the resources of a class. This allows to skip management of resources even if classes are included. Used to avoid to manage some resources when building Docker images.

  • auto_prereq (Boolean) (defaults to: true)

    If to automtically manage prerequisites. Set to false here to apply this value for all the PSICK profiles that honour this global setting. Use when you have duplicated resources.

  • enable_firstrun (Boolean) (defaults to: false)

    If to enable firstrun mode, a special one-time only, Puppet run where some specific, prerequisites, classes are applied.

  • noop_mode (Optional[Boolean]) (defaults to: lookup('noop_mode',Optional[Boolean],'first',undef))

    This parameter is deprecated and has no effect any more. If set, compilation fails. It has been replaced by noop_manage and noop_value. psick::noop_mode: true and no_noop on a specific class can be replaced by: psick::noop_manage: true psick::noop_value: false

  • noop_manage (Boolean) (defaults to: false)

    If to use the noop() function for all the classes included in this module. If this is true the noop($noop_value) function is called. Overriding any other noop setting (either set on client’s puppet.conf or elsewhere). This values is inherited by all the classes in psick module but can singularly overwritten in each of them.

  • noop_value (Boolean) (defaults to: false)

    The value to pass to noop() function if noop_manage is true. It applies to all the resources (and classes) declared in this module. Can be overridden is single classes using the relevant class parameter. If true: noop metaparamenter is set to true, resources are not applied If false: noop metaparameter is set to false, and any eventual noop setting is overridden: resources are always applied.

  • primary_ip (Optional[Stdlib::IP::Address]) (defaults to: fact('networking.ip'))

    The server primary IP address. Default value is the value of the $::networking fact.

  • mgmt_interface (Optional[String]) (defaults to: fact('networking.primary'))

    The management interface of the server. Default value is the value of the $::networking fact.

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

    The timezone to set on the system. Single entry point used by some PSICK profiles.

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

    An hash of custom settings which can be used to configure any settings which might be used in different profiles. This is not used in any existing PSICK profiles, but can be referenced in any custom profile classified via PSICK.

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

    An hash which describes general infrastructure endpoints which can be used by different (PSICK or local) profiles. Used in psick::proxy and whenever it might be needed to refer to a single endpoint used by differenet classes / profiles.

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

    An hash to configure behaviour of tp defines. It’s used to set resource defaults for tp::install, tp::conf and tp::dir.

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

    An hash of general firewall settings. Can be used and honoured by other psick profiles. Customise as needed.

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

    An hash of general monitor settings. Can be used and honoured by other psick profiles. Customise as needed.

  • force_ordering (Boolean) (defaults to: true)

    When enabled, as default, the psick module enforces ordering of the classes included in psick::pre -> psick::base -> psick::profiles. Disable only if you have unresolvable dependency loops or if you don’t want the PSICK class provisioning staged in different phases.

  • resources

    An hash of an Hash of any Puppet resource type to apply. Consider it as a catch all way to set on Hiera any resource of any type. You can always specify for each resource type the default parameters via the psick::resources_defaults Hiera key. See below for a sample usage. This is not actually a class parameter, but a Hiera key looked up using the merge behaviour configured via $resources_merge_behaviour

  • resources_merge_behaviour (Enum['first','hash','deep']) (defaults to: 'deep')

    Defines the lookup method to use to retrieve via hiera the psick::resources key

  • resources_defaults

    An Hash of resources with an Hash of default parameters to apply to the relevant resources. This is not actually a class parameter, but a key looked up using the merge behaviour configured via $resources_defaults_merge_behaviour

  • resources_defaults_merge_behaviour (Enum['first','hash','deep']) (defaults to: 'deep')

    Defines the lookup method to use to retrieve via hiera the psick::resources_defaults key

  • interfaces_hash (Hash) (defaults to: {})
  • osfamily_resources_merge_behaviour (Enum['first','hash','deep']) (defaults to: 'deep')
  • osfamily_resources_defaults_merge_behaviour (Enum['first','hash','deep']) (defaults to: 'deep')


106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'manifests/init.pp', line 106

class psick (

  # PSICK global vars
  Boolean $manage                                  = true,
  Boolean $auto_prereq                             = true,
  Boolean $enable_firstrun                         = false,

  Optional[Boolean] $noop_mode                     = lookup('noop_mode',Optional[Boolean],'first',undef), # lint:ignore:lookup_in_parameter
  Boolean $noop_manage                             = false,
  Boolean $noop_value                              = false,

  # General network settings
  Optional[Stdlib::IP::Address] $primary_ip = fact('networking.ip'),
  Optional[String] $mgmt_interface                 = fact('networking.primary'),
  Optional[String] $timezone                       = undef,
  Hash $interfaces_hash                            = {},

  # General endpoints and variables
  Hash $settings                                   = {},
  Hash $servers                                    = {},
  Hash $tp                                         = {},
  Hash $firewall                                   = {},
  Hash $monitor                                    = {},
  Boolean $force_ordering                          = true,

  # General resources
  # Hash $resources (lookup with $resources_merge_behaviour)                   = {},
  # Hash $resources_defaults (lookup with $resources_defaults_merge_behaviour) = {},
  Enum['first','hash','deep'] $resources_merge_behaviour          = 'deep',
  Enum['first','hash','deep'] $resources_defaults_merge_behaviour = 'deep',

  # $::os['family'] based resources
  # Hash $osfamily_resources (lookup with $osfamily_resources_merge_behaviour)                   = {},
  # Hash $osfamily_resources_defaults (lookup with $osfamily_resources_defaults_merge_behaviour) = {},
  Enum['first','hash','deep'] $osfamily_resources_merge_behaviour          = 'deep',
  Enum['first','hash','deep'] $osfamily_resources_defaults_merge_behaviour = 'deep',

) {
  if $noop_mode != undef {
    fail('psick::noop_mode parameter has been deprecated. Use $noop_manage and $noop_manage instead')
  }
  if $noop_manage {
    noop($noop_value)
  }

  # Resource defaults for Tiny Puppet defines
  Tp::Install {
    cli_enable   => $tp['cli_enable'],
    test_enable  => $tp['test_enable'],
    puppi_enable => $tp['puppi_enable'],
    debug        => $tp['debug'],
    data_module  => $tp['data_module'],
  }
  Tp::Conf {
    config_file_notify  => $tp['config_file_notify'],
    config_file_require => $tp['config_file_require'],
    debug               => $tp['debug'],
    data_module         => $tp['data_module'],
  }
  Tp::Dir {
    config_dir_notify  => $tp['config_dir_notify'],
    config_dir_require => $tp['config_dir_require'],
    debug              => $tp['debug'],
    data_module        => $tp['data_module'],
  }

  # Building of the $::psick::interfaces variable, usable in any class included
  # via or after psick.
  # By default are set main and mgmt interfaces based on sane facts values and
  # user params $primary_ip and $mgmt_interface
  $primary_interface =  $facts['networking']['primary']
  $interfaces_default = {
    main => {
      interface => $facts['networking']['primary'],
      address   => pick($primary_ip, $facts['networking']['interfaces'][$primary_interface]['ip']),
      netmask   => $facts['networking']['interfaces'][$primary_interface]['netmask'],
      network   => $facts['networking']['interfaces'][$primary_interface]['network'],
      hostname  => $facts['networking']['fqdn'],
    },
    mgmt => {
      interface => $mgmt_interface,
      address   => $facts['networking']['interfaces'][$mgmt_interface]['ip'],
      netmask   => $facts['networking']['interfaces'][$mgmt_interface]['netmask'],
      network   => $facts['networking']['interfaces'][$mgmt_interface]['network'],
      hostname  => $facts['networking']['fqdn'],
    },
  }
  $interfaces = deep_merge($interfaces_default, $interfaces_hash)

  # PSICK PRE, BASE CLASSES AND PROFILES + OPTIONAL FIRSTRUN MODE
  # The classes included here manage PSICK classification and
  # relevant class ordering
  if $facts['firstrun'] == 'done' or $enable_firstrun == false {
    contain psick::pre
    contain psick::base
    contain psick::profiles
    if $force_ordering {
      Class['psick::pre'] -> Class['psick::base'] -> Class['psick::profiles']
    }
  } else {
    contain psick::firstrun
    notify { "This catalog should be applied only at the first Puppen run\n": }
  }

  # Custom Resources management
  $resources = lookup('psick::resources',Hash,$resources_merge_behaviour, {})
  $resources_defaults = lookup('psick::resources_defaults',Hash,$resources_defaults_merge_behaviour, {})

  $resources.each |$k,$v| {
    if $k in keys($resources_defaults) {
      $resource_defaults = $resources_defaults[$k]
    } else {
      $resource_defaults = {}
    }
    create_resources( $k, $v, $resource_defaults )
  }

  # Custom Resources management
  $osfamily_resources = lookup('psick::osfamily_resources',Hash,$osfamily_resources_merge_behaviour, {})
  $osfamily_resources_defaults = lookup('psick::osfamily_resources_defaults',Hash,$osfamily_resources_defaults_merge_behaviour, {})
  $osfamily_resources.each |$k,$v| {
    if $facts['os']['family'] == $k {
      if $k in $osfamily_resources_defaults {
        $os_defaults = $osfamily_resources_defaults[$k]
      } else {
        $os_defaults = {}
      }

      create_resources( $k, $v, $os_defaults )
    }
  }
}