Defined Type: nhc::conf

Defined in:
manifests/conf.pp

Summary

Manage NHC configurations

Overview

Examples:

Define additional NHC configuration

nhc::conf { 'nhc-cron':
  settings          => { 'NHC_RM' => 'slurm' },
  settings_host     => { 'c0001' => { 'FOO' => 'bar' }},
  checks            => { '*' => ['check_fs_free /tmp 10%'] },
  config_overrides  => { 'HOSTNAME' => '"$HOSTNAME_S"' },
}

Parameters:

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

    State of nhc::conf

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

    Checks to add to the configuration file

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

    Settings to add to the configuration file

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

    Settings specific to a hosts to add to the configuration file

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

    Overrides for configuration in /etc/sysconfig/$name

  • 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: $name)

    Value for NAME

  • conf_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to NHC configuration directry. Defaults to /etc/nhc

  • conf_file (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path for this configuration file. Defaults to /etc/nhc/$name.conf

  • include_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to directory containing NHC checks. Defaults to /etc/nhc/scripts

  • sysconfig_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to sysconfig file. Defaults to /etc/sysconfig/$name

  • log_file (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to log file. Defaults to /var/log/$name.log



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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'manifests/conf.pp', line 38

define nhc::conf (
  Enum['present', 'absent'] $ensure               = 'present',
  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                            = $name,
  Optional[Stdlib::Absolutepath] $conf_dir        = undef,
  Optional[Stdlib::Absolutepath] $conf_file       = undef,
  Optional[Stdlib::Absolutepath] $include_dir     = undef,
  Optional[Stdlib::Absolutepath] $sysconfig_path  = undef,
  Optional[Stdlib::Absolutepath] $log_file        = undef,
) {
  case $ensure {
    'present': {
      $directory_ensure = 'directory'
      $_directory_force = undef
      $file_ensure      = 'file'
    }
    'absent': {
      $directory_ensure = 'absent'
      $_directory_force = true
      $file_ensure      = 'absent'
    }
    default: {}
  }

  include nhc

  $_conf_dir = pick($conf_dir, $nhc::conf_dir)
  $_conf_file = pick($conf_file, "${_conf_dir}/${name}.conf")
  $_include_dir = pick($include_dir, $nhc::include_dir)
  $_sysconfig_path = pick($sysconfig_path, "/etc/sysconfig/${name}")
  $_log_file = pick($log_file, "/var/log/${name}.log")

  $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)

  if $_conf_dir != $nhc::conf_dir {
    file { $_conf_dir:
      ensure  => $directory_ensure,
      force   => $_directory_force,
      owner   => 'root',
      group   => 'root',
      mode    => '0700',
      require => Package['lbnl-nhc'],
    }
  }

  if $_conf_file != $nhc::conf_file {
    file { $_conf_file:
      ensure  => $file_ensure,
      content => template('nhc/nhc.conf.erb'),
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      require => File[$_conf_dir],
    }
  }

  if $_include_dir != $nhc::include_dir {
    file { $_include_dir:
      ensure  => $directory_ensure,
      owner   => 'root',
      group   => 'root',
      mode    => '0700',
      require => Package['lbnl-nhc'],
    }
  }

  if $_sysconfig_path != $nhc::sysconfig_path {
    file { $_sysconfig_path:
      ensure  => $file_ensure,
      content => template('nhc/sysconfig.erb'),
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
    }
  }
}