Puppet Class: patching

Inherits:
patching::params
Defined in:
manifests/init.pp

Summary

allows global customization of the patching resources

Overview

Examples:

Basic usage

include patching

Customizing script location

class {'patching':
  bin_dir => '/my/custom/patching/scripts',
}

Customizing the owner/group/mode of the scripts

class {'patching':
  owner => 'svc_patching',
  group => 'svc_patching',
  mode  => '0700',
}

Customizing from hiera

patching::bin_dir: '/my/custom/app/patching/dir'
patching::owner: 'svc_patching'
patching::group: 'svc_patching'
patching::mode: '0700'

Deploying scripts from hiera

patching::scripts:
  custom_app_pre_patch.sh:
    source: 'puppet:///mymodule/patching/custom_app_pre_patch.sh'
  custom_app_post_patch.sh:
    source: 'puppet:///mymodule/patching/custom_app_post_patch.sh'

Parameters:

  • patching_dir (Any) (defaults to: $patching::params::patching_dir)

    Global directory as the base for ‘bin_dir` and `log_dir`

  • bin_dir (Any) (defaults to: $patching::params::bin_dir)

    Global directory where the scripts will be installed

  • log_dir (Any) (defaults to: $patching::params::log_dir)

    Directory where log files will be written during patching

  • owner (Any) (defaults to: $patching::params::owner)

    Default owner of installed scripts

  • group (Any) (defaults to: $patching::params::group)

    Default group of installed scripts

  • mode (Any) (defaults to: $patching::params::mode)

    Default file mode of installed scripts

  • scripts (Optional[Hash]) (defaults to: undef)

    Hash of script resources to instantiate. Useful for declaring script installs from hiera.



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

class patching (
  $patching_dir           = $patching::params::patching_dir,
  $bin_dir                = $patching::params::bin_dir,
  $log_dir                = $patching::params::log_dir,
  $owner                  = $patching::params::owner,
  $group                  = $patching::params::group,
  $mode                   = $patching::params::mode,
  Optional[Hash] $scripts = undef,
) inherits patching::params {
  if $patching_dir {
    ensure_resource('file', $patching_dir, {
      ensure => directory,
      owner  => $owner,
      group  => $group,
    })
  }

  if $bin_dir {
    ensure_resource('file', $bin_dir, {
      ensure => directory,
      owner  => $owner,
      group  => $group,
    })
  }

  if $log_dir {
    ensure_resource('file', $log_dir, {
      ensure => directory,
      owner  => $owner,
      group  => $group,
    })
  }

  if $scripts {
    $defaults = {
      bin_dir => $bin_dir,
      owner   => $owner,
      group   => $group,
      mode    => $mode,
    }
    ensure_resources('patching::script', $scripts, $defaults)
  }
}