-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathservice.pp
49 lines (46 loc) · 1.93 KB
/
service.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# == Class puppet_agent::service
#
# This class is meant to be called from puppet_agent.
# It ensures that managed services are running.
#
class puppet_agent::service{
assert_private()
# Starting with puppet6 collections we no longer carry the mcollective service
if $::puppet_agent::collection != 'PC1' and $::puppet_agent::collection != 'puppet5' {
$_service_names = delete($::puppet_agent::service_names, 'mcollective')
} else {
$_service_names = $::puppet_agent::service_names
}
if $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '10' and versioncmp("${::clientversion}", '5.0.0') < 0 {
# Skip managing service, upgrade script will handle it.
} elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '11' and $puppet_agent::aio_upgrade_required {
# Only use script if we just performed an upgrade.
$_logfile = "${::env_temp_variable}/solaris_start_puppet.log"
# We'll need to pass the names of the services to start to the script
$_service_names_arg = join($_service_names, ' ')
notice ("Puppet service start log file at ${_logfile}")
file { "${::env_temp_variable}/solaris_start_puppet.sh":
ensure => file,
source => 'puppet:///modules/puppet_agent/solaris_start_puppet.sh',
mode => '0755',
}
-> exec { 'solaris_start_puppet.sh':
command => "${::env_temp_variable}/solaris_start_puppet.sh ${::puppet_agent_pid} ${_service_names_arg} 2>&1 > ${_logfile} &",
path => '/usr/bin:/bin:/usr/sbin',
}
file { ['/var/opt/lib', '/var/opt/lib/pe-puppet', '/var/opt/lib/pe-puppet/state']:
ensure => directory,
}
}
# as per class comment, this is where we actually manage the service proper.
if $::puppet_agent::manage_service {
$_service_names.each |$service| {
service { $service:
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
}
}
}