forked from theforeman/puppet-puppet
/
service.pp
71 lines (66 loc) · 1.83 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Set up the puppet client as a service
class puppet::agent::service {
case $::puppet::runmode {
'service': {
service {'puppet':
ensure => running,
name => $puppet::service_name,
hasstatus => true,
hasrestart => $puppet::agent_restart_command != undef,
enable => true,
restart => $puppet::agent_restart_command,
}
if $::osfamily != 'windows' {
cron { 'puppet':
ensure => absent,
}
}
}
'cron': {
service {'puppet':
ensure => stopped,
name => $puppet::service_name,
hasstatus => true,
enable => false,
}
$command = $puppet::cron_cmd ? {
undef => "/usr/bin/env puppet agent --config ${puppet::dir}/puppet.conf --onetime --no-daemonize",
default => $puppet::cron_cmd,
}
if $::osfamily == 'windows' {
fail("Currently we don't support setting cron on windows.")
} else {
$times = ip_to_cron($puppet::runinterval)
cron { 'puppet':
command => $command,
user => root,
hour => $times[0],
minute => $times[1],
}
}
}
'systemd.timer': {
$times = ip_to_cron($puppet::runinterval)
file { '/tmp/puppetcron.timer':
#file { '/etc/systemd/system/puppetcron.timer':
content => template('puppet/agent/systemd.puppetcron.timer.erb')
}
}
'none': {
service { 'puppet':
ensure => stopped,
name => $puppet::service_name,
hasstatus => true,
enable => false,
}
if $::osfamily != 'windows' {
cron { 'puppet':
ensure => absent,
}
}
}
default: {
fail("Runmode of ${puppet::runmode} not supported by puppet::agent::config!")
}
}
}