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
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
|
# File 'manifests/client.pp', line 14
class sensu::client (
Boolean $hasrestart = $::sensu::hasrestart,
$log_level = $::sensu::log_level,
$windows_logrotate = $::sensu::windows_logrotate,
$windows_log_size = $::sensu::windows_log_size,
$windows_log_number = $::sensu::windows_log_number,
) {
# Service
if $::sensu::manage_services {
case $::sensu::client {
true: {
$service_ensure = 'running'
$service_enable = true
}
default: {
$service_ensure = 'stopped'
$service_enable = false
}
}
if $::osfamily == 'windows' {
file { 'C:/opt/sensu/bin/sensu-client.xml':
ensure => file,
content => template("${module_name}/sensu-client.erb"),
}
exec { 'install-sensu-client':
provider => 'powershell',
command => "New-Service -Name sensu-client -BinaryPathName c:\\opt\\sensu\\bin\\sensu-client.exe -DisplayName 'Sensu Client' -StartupType Automatic",
unless => 'if (Get-Service sensu-client -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }',
before => Service['sensu-client'],
require => File['C:/opt/sensu/bin/sensu-client.xml'],
}
}
service { 'sensu-client':
ensure => $service_ensure,
enable => $service_enable,
hasrestart => $hasrestart,
subscribe => [
Class['sensu::package'],
Sensu_client_config[$::fqdn],
Class['sensu::rabbitmq::config'],
],
}
}
# Config
if $::sensu::_purge_config and !$::sensu::client {
$file_ensure = 'absent'
} else {
$file_ensure = 'present'
}
file { "${sensu::conf_dir}/client.json":
ensure => $file_ensure,
owner => $::sensu::user,
group => $::sensu::group,
mode => $::sensu::file_mode,
}
$socket_config = {
bind => $::sensu::client_bind,
port => $::sensu::client_port,
}
sensu_client_config { $::fqdn:
ensure => $file_ensure,
base_path => $::sensu::conf_dir,
client_name => $::sensu::client_name,
address => $::sensu::client_address,
socket => $socket_config,
subscriptions => $::sensu::subscriptions,
safe_mode => $::sensu::safe_mode,
custom => $::sensu::client_custom,
keepalive => $::sensu::client_keepalive,
redact => $::sensu::redact,
deregister => $::sensu::client_deregister,
deregistration => $::sensu::client_deregistration,
registration => $::sensu::client_registration,
http_socket => $::sensu::client_http_socket,
servicenow => $::sensu::client_servicenow,
ec2 => $::sensu::client_ec2,
chef => $::sensu::client_chef,
puppet => $::sensu::client_puppet,
}
}
|