Puppet Class: osg::cacerts::updater

Defined in:
manifests/cacerts/updater.pp

Summary

Manage OSG CA certs updater

Overview

Parameters:

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

    State of the resources managed by this class disabled will install the necessary packages but disable the service

  • min_age (Integer) (defaults to: 23)

    Min time between running updater

  • max_age (Integer) (defaults to: 72)

    Max time between running updater

  • random_wait (Integer) (defaults to: 30)

    Random wait time

  • quiet (Boolean) (defaults to: true)

    Only display errors

  • logfile (Variant[Boolean,Undef,String]) (defaults to: false)

    Path to logfile

  • package_name (String) (defaults to: 'osg-ca-certs-updater')

    Package name

  • package_ensure (String) (defaults to: 'UNSET')

    Package ensure value

  • service_name (String) (defaults to: 'osg-ca-certs-updater-cron')

    Service name

  • service_ensure (String) (defaults to: 'UNSET')

    Service ensure value

  • service_enable (String) (defaults to: 'UNSET')

    Service enable value

  • config_replace (Boolean) (defaults to: true)

    Should the cron config be replaced



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
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
# File 'manifests/cacerts/updater.pp', line 29

class osg::cacerts::updater (
  Enum['present', 'absent', 'disabled'] $ensure = 'present',
  Integer $min_age = 23,
  Integer $max_age = 72,
  Integer $random_wait = 30,
  Boolean $quiet = true,
  Variant[Boolean,Undef,String] $logfile = false,
  String $package_name = 'osg-ca-certs-updater',
  String $package_ensure = 'UNSET',
  String $service_name = 'osg-ca-certs-updater-cron',
  String $service_ensure = 'UNSET',
  String $service_enable = 'UNSET',
  Boolean $config_replace = true,
) {

  require 'osg::cacerts'

  case $ensure {
    'present': {
      $package_ensure_default = 'installed'
      $service_ensure_default = 'running'
      $service_enable_default = true
    }
    'absent': {
      $package_ensure_default = 'absent'
      $service_ensure_default = 'stopped'
      $service_enable_default = false
    }
    'disabled': {
      $package_ensure_default = 'installed'
      $service_ensure_default = 'stopped'
      $service_enable_default = false
    }
    default: {
      fail("Module osg::cacerts::updater: Parameter 'ensure' must be 'present', 'absent' or 'disabled': ${ensure} given")
    }
  }

  $package_ensure_real = $package_ensure ? {
    'UNSET' => $package_ensure_default,
    default => $package_ensure,
  }

  $service_ensure_real = $service_ensure ? {
    'UNSET' => $service_ensure_default,
    default => $service_ensure,
  }

  $service_enable_real = $service_enable ? {
    'UNSET' => $service_enable_default,
    default => $service_enable,
  }

  $min_age_arg = $min_age ? {
    /undef|false/ => 'UNSET',
    default       => "-a ${min_age}",
  }
  $max_age_arg = $max_age ? {
    /undef|false/ => 'UNSET',
    default       => "-x ${max_age}",
  }
  $random_wait_arg = $random_wait ? {
    /undef|false/ => 'UNSET',
    default       => "-r ${random_wait}",
  }
  $quiet_arg = $quiet ? {
    true          => '-q',
    default       => 'UNSET',
  }
  $logfile_arg = $logfile ? {
    false   => 'UNSET',
    'undef' => 'UNSET',
    default => "-l ${logfile}",
  }

  $args_array = [ $min_age_arg, $max_age_arg, $random_wait_arg, $quiet_arg, $logfile_arg ]
  $args = join(reject($args_array, 'UNSET'), ' ')

  package { 'osg-ca-certs-updater':
    ensure  => $package_ensure_real,
    name    => $package_name,
    before  => File['/etc/cron.d/osg-ca-certs-updater'],
    require => Yumrepo['osg'],
  }

  service { 'osg-ca-certs-updater-cron':
    ensure     => $service_ensure_real,
    enable     => $service_enable_real,
    name       => $service_name,
    hasstatus  => true,
    hasrestart => true,
    subscribe  => File['/etc/cron.d/osg-ca-certs-updater'],
  }

  file { '/etc/cron.d/osg-ca-certs-updater':
    ensure  => present,
    content => template('osg/osg-ca-certs-updater.erb'),
    replace => $config_replace,
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
  }
}