Puppet Class: nhc

Defined in:
manifests/init.pp

Summary

Manage Node Health Check (NHC)

Overview

Examples:

include ::nhc

Parameters:

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    State of NHC resources

  • install_method (Enum['repo','package','source']) (defaults to: 'source')

    The method used to install NHC. Using repo will require the Yumrepo resource if repo_name is defined.

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

    The ensure state of package if using install_method of repo or package.

  • version (String) (defaults to: '1.4.3')

    The version of NHC to install.

  • package_release (String) (defaults to: '1')

    The package release NHC to install. Not used if install_method is source.

  • install_source (Optional[Variant[Stdlib::HTTPUrl,Stdlib::HTTPSUrl]]) (defaults to: undef)

    The source of install. For install_method of package this is URL to package For install_method of source this is git source URL

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

    Name of the NHC package, not used with install_method of source.

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

    The repo name for NHC, only used with install_method of repo.

  • source_dependencies (Array) (defaults to: ['automake','make'])

    The package dependencies for source install.

  • libexec_dir (Stdlib::Absolutepath) (defaults to: '/usr/libexec')

    Location for libexec directory, OS dependent.

  • checks (Variant[Hash, Array]) (defaults to: [])

    NHC checks for nhc.conf

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

    Settings to add to nhc.conf

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

    Host specific settings for nhc.conf

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

    Settings to add to /etc/sysconfig/nhc

  • detached_mode (Boolean) (defaults to: false)

    Value for DETACHED_MODE

  • detached_mode_fail_nodata (Boolean) (defaults to: false)

    Value for DETACHED_MODE_FAIL_NODATA

  • program_name (String) (defaults to: 'nhc')

    Value for NAME

  • conf_dir (Stdlib::Absolutepath) (defaults to: '/etc/nhc')

    Path to NHC configuration directry

  • conf_file (Stdlib::Absolutepath) (defaults to: '/etc/nhc/nhc.conf')

    Path for this configuration file

  • include_dir (Stdlib::Absolutepath) (defaults to: '/etc/nhc/scripts')

    Path to directory containing NHC checks

  • log_file (Stdlib::Absolutepath) (defaults to: '/var/log/nhc.log')

    Path to log file

  • sysconfig_path (Stdlib::Absolutepath) (defaults to: '/etc/sysconfig/nhc')

    Path to sysconfig file

  • manage_logrotate (Boolean) (defaults to: true)

    Boolean that sets if logrotate resources should be managed

  • log_rotate_every (String) (defaults to: 'weekly')

    Frequency of logrotation

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

    Hash passed to nhc::custom_check



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

class nhc (
  Enum['present', 'absent'] $ensure   = 'present',

  # packages
  Enum['repo','package','source'] $install_method = 'source',
  Optional[String] $package_ensure      = undef,
  String $version = '1.4.3',
  String $package_release = '1',
  Optional[Variant[Stdlib::HTTPUrl,Stdlib::HTTPSUrl]]
  $install_source                     = undef,
  Optional[String] $package_name        = undef,
  Optional[String] $repo_name           = undef,
  Array $source_dependencies            = ['automake','make'],
  Stdlib::Absolutepath $libexec_dir     = '/usr/libexec',

  # NHC configuration
  Variant[Hash, Array] $checks          = [],
  Hash $settings                        = {},
  Hash $settings_host                   = {},
  Hash $config_overrides                = {},
  Boolean $detached_mode                = false,
  Boolean $detached_mode_fail_nodata    = false,
  String $program_name                  = 'nhc',
  Stdlib::Absolutepath $conf_dir        = '/etc/nhc',
  Stdlib::Absolutepath $conf_file       = '/etc/nhc/nhc.conf',
  Stdlib::Absolutepath $include_dir     = '/etc/nhc/scripts',
  Stdlib::Absolutepath $log_file        = '/var/log/nhc.log',
  Stdlib::Absolutepath $sysconfig_path  = '/etc/sysconfig/nhc',
  Boolean $manage_logrotate             = true,
  String $log_rotate_every              = 'weekly',
  Hash $custom_checks                   = {},
) {
  case $ensure {
    'present': {
      if $install_method == 'repo' {
        $_package_ensure  = pick($package_ensure, "${version}-${package_release}.el${facts['os']['release']['major']}")
      } else {
        $_package_ensure  = pick($package_ensure, 'installed')
      }
      $directory_ensure = 'directory'
      $_directory_force = undef
      $file_ensure      = 'file'
    }
    'absent': {
      $_package_ensure  = 'absent'
      $directory_ensure = 'absent'
      $_directory_force = true
      $file_ensure      = 'absent'
    }
    default: {}
  }

  if $install_method == 'repo' {
    if $repo_name {
      $_package_require = Yumrepo[$repo_name]
    } else {
      $_package_require = undef
    }
    $_install_source              = undef
    $_package_name                = pick($package_name, 'lbnl-nhc')
  } elsif $install_method == 'package' {
    $_default_package_name   = "lbnl-nhc-${version}-${package_release}.el${facts['os']['release']['major']}.noarch"
    $_default_install_source = "https://github.com/mej/nhc/releases/download/${version}/${_default_package_name}.rpm"
    $_package_require             = undef
    $_install_source = pick($install_source, $_default_install_source)
    $_package_name = pick($package_name, $_default_package_name)
  } else {
    $_install_source = pick($install_source, 'https://github.com/mej/nhc.git')
  }

  $default_configs = {
    'CONFDIR'                   => $conf_dir,
    'CONFFILE'                  => $conf_file,
    'DETACHED_MODE'             => $detached_mode,
    'DETACHED_MODE_FAIL_NODATA' => $detached_mode_fail_nodata,
    'INCDIR'                    => $include_dir,
    'NAME'                      => $program_name,
  }

  $configs = merge($default_configs, $config_overrides)

  contain nhc::install
  contain nhc::config

  Class['nhc::install']
  -> Class['nhc::config']

  $custom_checks.each |$name, $params| {
    nhc::custom_check { $name: * => $params }
  }
}