-
Notifications
You must be signed in to change notification settings - Fork 289
/
Copy pathpackage.pp
179 lines (155 loc) · 4.44 KB
/
package.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# = Class: sensu::package
#
# Installs the Sensu packages
#
class sensu::package {
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}
case $::osfamily {
'Debian': {
$pkg_title = 'sensu'
$pkg_name = 'sensu'
$pkg_source = undef
if $sensu::manage_repo {
class { '::sensu::repo::apt': }
}
if $sensu::manage_repo and $sensu::install_repo {
include ::apt
$pkg_require = Class['apt::update']
}
else {
$pkg_require = undef
}
}
'RedHat': {
$pkg_title = 'sensu'
$pkg_name = 'sensu'
$pkg_source = undef
if $sensu::manage_repo {
class { '::sensu::repo::yum': }
}
$pkg_require = undef
}
'windows': {
$repo_require = undef
$pkg_version = inline_template("<%= scope.lookupvar('sensu::version').sub(/(.*)\\./, '\\1-') %>")
$pkg_title = 'sensu'
$pkg_name = 'Sensu'
$pkg_source = "C:\\Windows\\Temp\\sensu-${pkg_version}.msi"
$pkg_require = "Remote_file[${pkg_source}]"
remote_file { $pkg_source:
ensure => present,
source => "http://repositories.sensuapp.org/msi/sensu-${pkg_version}.msi",
checksum => $::sensu::package_checksum,
}
}
default: { fail("${::osfamily} not supported yet") }
}
package { $pkg_title:
ensure => $sensu::version,
name => $pkg_name,
source => $pkg_source,
require => $pkg_require,
}
if $::sensu::sensu_plugin_provider {
$plugin_provider = $::sensu::sensu_plugin_provider
} else {
$plugin_provider = $sensu::use_embedded_ruby ? {
true => 'sensu_gem',
default => 'gem',
}
}
if $plugin_provider =~ /gem/ and $::sensu::gem_install_options {
package { $::sensu::sensu_plugin_name :
ensure => $sensu::sensu_plugin_version,
provider => $plugin_provider,
install_options => $::sensu::gem_install_options,
}
} else {
package { $::sensu::sensu_plugin_name :
ensure => $sensu::sensu_plugin_version,
provider => $plugin_provider,
}
}
if $::osfamily != 'windows' {
file { '/etc/default/sensu':
ensure => file,
content => template("${module_name}/sensu.erb"),
owner => '0',
group => '0',
mode => '0444',
require => Package['sensu'],
}
}
file { [ $sensu::conf_dir, "${sensu::conf_dir}/handlers", "${sensu::conf_dir}/checks", "${sensu::conf_dir}/filters", "${sensu::conf_dir}/extensions", "${sensu::conf_dir}/mutators" ]:
ensure => directory,
owner => $sensu::user,
group => $sensu::group,
mode => $sensu::dir_mode,
purge => $sensu::_purge_config,
recurse => true,
force => true,
require => Package[$pkg_name],
}
if $sensu::manage_handlers_dir {
file { "${sensu::etc_dir}/handlers":
ensure => directory,
mode => $sensu::dir_mode,
owner => $sensu::user,
group => $sensu::group,
purge => $sensu::_purge_handlers,
recurse => true,
force => true,
require => Package[$pkg_name],
}
}
file { ["${sensu::etc_dir}/extensions", "${sensu::etc_dir}/extensions/handlers"]:
ensure => directory,
mode => $sensu::dir_mode,
owner => $sensu::user,
group => $sensu::group,
purge => $sensu::_purge_extensions,
recurse => true,
force => true,
require => Package[$pkg_name],
}
if $sensu::manage_mutators_dir {
file { "${sensu::etc_dir}/mutators":
ensure => directory,
mode => $sensu::dir_mode,
owner => $sensu::user,
group => $sensu::group,
purge => $sensu::_purge_mutators,
recurse => true,
force => true,
require => Package[$pkg_name],
}
}
if $sensu::_manage_plugins_dir {
file { "${sensu::etc_dir}/plugins":
ensure => directory,
mode => $sensu::dir_mode,
owner => $sensu::user,
group => $sensu::group,
purge => $sensu::_purge_plugins,
recurse => true,
force => true,
require => Package[$pkg_name],
}
}
if $sensu::manage_user {
user { 'sensu':
ensure => 'present',
system => true,
home => '/opt/sensu',
shell => '/bin/false',
comment => 'Sensu Monitoring Framework',
}
group { 'sensu':
ensure => 'present',
system => true,
}
}
file { "${sensu::etc_dir}/config.json": ensure => absent }
}