-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathdefault.rb
437 lines (390 loc) · 10.7 KB
/
default.rb
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
sensu_backend 'default' do
action [:install, :init]
username node['username']
password node['password']
debug true
end
sensu_agent 'default'
sensu_ctl 'default' do
action [:install, :configure]
username node['username']
password node['password']
debug true
end
sensu_user 'doofus' do
password_hash '$2y$12$OrEQ61blxyTFi3PJHeJ94ej/Z857eSAnAdlSD4Kn7ywItTLrzTqVy'
groups %w(view admin managers)
disabled true
end
sensu_user 'reinstated' do
password_hash '$2y$12$yga83H/KqKFKDYnLogQ6CeN3xrFmhVwMdVkh.hRPX/BhF2NJfYq8O'
groups %w(view)
end
sensu_namespace 'test-org' do
action :create
end
sensu_check 'cron' do
command '/bin/true'
cron '@hourly'
subscriptions %w(dad_jokes production)
handlers %w(pagerduty email)
labels(environment: 'production', region: 'us-west-2')
annotations(runbook: 'https://www.xkcd.com/378/')
publish false
ttl 100
high_flap_threshold 60
low_flap_threshold 20
subdue(days: { all: [{ begin: '12:00 AM', end: '11:59 PM' },
{ begin: '11:00 PM', end: '1:00 AM' }] })
action :create
end
sensu_check 'cron-test-org' do
command '/bin/true'
cron '@hourly'
subscriptions %w(dad_jokes production)
namespace 'test-org'
handlers %w(pagerduty email)
labels(environment: 'production', region: 'us-west-2')
annotations(runbook: 'https://www.xkcd.com/378/')
publish false
ttl 100
high_flap_threshold 60
low_flap_threshold 20
subdue(days: { all: [{ begin: '12:00 AM', end: '11:59 PM' },
{ begin: '11:00 PM', end: '1:00 AM' }] })
action :create
end
assets = data_bag_item('sensu', 'assets')
assets.each do |name, property|
next if name == 'id'
sensu_asset name do
url property['url']
sha512 property['checksum']
namespace property['namespace']
headers property['headers'] if property['headers']
end
end
sensu_asset 'multi-build' do
builds [
{
'filters' => [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'",
"entity.system.platform_family == 'debian'",
"entity.system.platform_version.split('.')[0] == '9'",
],
'sha512' => 'a909f6eef2785302f648d5289fddfdd97014984e25751abb94ea70226ef8c5e56f9e333c054d79734c5f165f93494f34943aa9aa1ed06297fac599ff57328c27',
'url' => 'https://assets.bonsai.sensu.io/058af8cde8fbdd97cfebf81a2565346e404210d5/sensu-plugins-postgres_4.0.0-pre-jef.1_debian9_linux_amd64.tar.gz',
},
{
'filters' => [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'",
"entity.system.platform_family == 'debian'",
],
'sha512' => 'b832ba248472e6c2713f60e946af322a8373e2144e6331afa6663ca13818b3c192e63f507dca1126d9b83b6c636b176a0e8e10a2a42292f457bf099f806ca57f',
'url' => 'https://assets.bonsai.sensu.io/058af8cde8fbdd97cfebf81a2565346e404210d5/sensu-plugins-postgres_4.0.0-pre-jef.1_debian_linux_amd64.tar.gz',
},
{
'filters' => [],
'sha512' => '555889017fcbcc6319f08097b79c3efccc3bf8ed0f8e59913ff7a508d4fe3d3b347118de11961657cd8504bdfd32af51f3c4add4ac639e378e82a05178248853',
'url' => 'https://assets.bonsai.sensu.io/058af8cde8fbdd97cfebf81a2565346e404210d5/sensu-plugins-postgres_4.0.0-pre-jef.1_centos6_linux_amd64.tar.gz',
},
]
end
sensu_handler 'slack' do
type 'pipe'
env_vars ['SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX']
command 'sensu-slack-handler --channel monitoring'
runtime_assets %w(sensu-slack-handler)
end
sensu_handler 'slack-test-org' do
type 'pipe'
env_vars ['SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX']
command 'sensu-slack-handler --channel monitoring'
namespace 'test-org'
runtime_assets %w(sensu-slack-handler)
end
sensu_handler 'tcp_handler' do
type 'tcp'
socket(
host: '127.0.0.1',
port: 4444
)
timeout 30
end
sensu_handler 'udp_handler' do
type 'udp'
socket(
host: '127.0.0.1',
port: 4444
)
timeout 30
end
sensu_handler 'notify_the_world' do
type 'set'
handlers %w(slack tcp_handler udp_handler)
end
sensu_filter 'production_filter' do
filter_action 'allow'
expressions [
"event.Entity.Environment == 'production'",
]
end
sensu_filter 'development_filter' do
filter_action 'deny'
expressions [
"event.Entity.Environment == 'production'",
]
end
sensu_filter 'state_change_only' do
filter_action 'allow'
expressions [
'event.Check.Occurrences == 1',
]
end
sensu_filter 'filter_interval_60_hourly' do
filter_action 'allow'
expressions [
'event.Check.Interval == 60',
'event.Check.Occurrences == 1 || event.Check.Occurrences % 60 == 0',
]
end
sensu_filter 'nine_to_fiver' do
filter_action 'allow'
expressions [
'weekday(event.Timestamp) >= 1 && weekday(event.Timestamp) <= 5',
'hour(event.Timestamp) >= 9 && hour(event.Timestamp) <= 17',
]
end
sensu_filter 'nine_to_fiver_test_org' do
filter_action 'allow'
expressions [
'weekday(event.Timestamp) >= 1 && weekday(event.Timestamp) <= 5',
'hour(event.Timestamp) >= 9 && hour(event.Timestamp) <= 17',
]
namespace 'test-org'
end
sensu_mutator 'example-mutator' do
command 'example_mutator.rb'
timeout 60
end
sensu_mutator 'example-mutator-test-org' do
command 'example_mutator.rb'
namespace 'test-org'
timeout 60
end
sensu_entity 'example-entity' do
entity_class 'proxy'
subscriptions ['example-entity']
labels(environment: 'production', region: 'us-west-2')
annotations(runbook: 'https://www.xkcd.com/378/')
redact ['snmp_community_string']
system(
'hostname': 'example-hypervisor',
'platform': 'Citrix Hypervisor',
'platform_version': '8.1.0',
'network': {
'interfaces': [
{
'name': 'lo',
'addresses': ['127.0.0.1/8'],
},
{
'name': 'xapi0',
'mac': '52:54:00:20:1b:3c',
'addresses': ['172.0.1.72/24'],
},
],
}
)
end
sensu_entity 'example-entity-test-org' do
entity_class 'proxy'
subscriptions ['example-entity-test-org']
namespace 'test-org'
labels(environment: 'production', region: 'us-west-2')
annotations(runbook: 'https://www.xkcd.com/378/')
redact ['snmp_community_string']
system(
'hostname': 'example-hypervisor',
'platform': 'Citrix Hypervisor',
'platform_version': '8.1.0',
'network': {
'interfaces': [
{
'name': 'lo',
'addresses': ['127.0.0.1/8'],
},
{
'name': 'xapi0',
'mac': '52:54:00:20:1b:3c',
'addresses': ['172.0.1.72/24'],
},
],
}
)
end
sensu_hook 'restart_cron_service' do
command 'sudo service cron restart'
timeout 60
end
sensu_hook 'restart_cron_service_test_org' do
command 'sudo service cron restart'
timeout 60
namespace 'test-org'
end
sensu_role 'read_only' do
namespace 'test-org'
rules [ { resource_names: ['*'], verbs: %w(get list) } ]
end
sensu_cluster_role 'all_access' do
rules [
{
resource_names: %w( assets checks entities events filters handlers hooks mutators rolebindings roles silenced cluster clusterrolebindings clusterroles namespaces users authproviders license ),
verbs: %w( get list create update delete ),
},
]
end
sensu_role_binding 'alice_read_only' do
namespace 'test-org'
role_name 'read_only'
role_type 'Role'
subjects [ { name: 'alice', type: 'user' } ]
end
sensu_cluster_role_binding 'cluster_admins-all_access' do
role_name 'all_access'
role_type 'ClusterRole'
subjects [ { name: 'cluster-admins', type: 'Group' } ]
end
sensu_active_directory 'example-active-directory' do
servers [{
'host': '127.0.0.1',
'group_search': {
'base_dn': 'dc=acme,dc=org',
},
'user_search': {
'base_dn': 'dc=acme,dc=org',
},
}]
end
sensu_active_directory 'example-active-directory-alias' do
servers [{
'host': '127.0.0.1',
'group_search': {
'base_dn': 'dc=acme,dc=org',
},
'user_search': {
'base_dn': 'dc=acme,dc=org',
},
}]
end
sensu_auth_oidc 'fake_okta' do
additional_scopes %w(groups email)
client_id 'a8e43af034e7f2608780'
# Demo only! The client secret value should come from somewhere like chef-vault
client_secret 'b63968394be6ed2edb61c93847ee792f31bf6216'
redirect_uri 'http://sensu-backend.example.com:8080/api/enterprise/authentication/v2/oidc/callback'
server 'https://oidc.example.com:9031'
end
sensu_auth_ldap 'example-auth-ldap' do
auth_servers [{
'host': '127.0.0.1',
'group_search': {
'base_dn': 'dc=acme,dc=org',
},
'user_search': {
'base_dn': 'dc=acme,dc=org',
},
}]
end
sensu_auth_ldap 'example-auth-ldap-alias' do
servers [{
'host': '127.0.0.1',
'group_search': {
'base_dn': 'dc=acme,dc=org',
},
'user_search': {
'base_dn': 'dc=acme,dc=org',
},
}]
end
sensu_secrets_provider 'vault' do
provider_type 'VaultProvider'
address 'https://vaultserver.example.com:8200'
max_retries 2
rate_limiter(
'limit': 10,
'burst': 100
)
timeout '60s'
token 'yourVaultToken'
version 'v1'
end
sensu_secret 'env-secret' do
namespace 'test-org'
id 'CONSUL_TOKEN'
secrets_provider 'env'
end
sensu_secret 'vault-secret' do
namespace 'test-org'
id 'secret/consul#token'
secrets_provider 'vault'
end
sensu_secret 'env-secret-default' do
namespace 'default'
id 'CONSUL_TOKEN'
secrets_provider 'env'
end
sensu_etcd_replicator 'insecure_role_replicator' do
insecure true
url 'http://127.0.0.1:2379'
resource 'Role'
end
sensu_etcd_replicator 'role_replicator' do
cert '/etc/ssl/fake.pem'
key '/etc/ssl/fake.key'
url 'http://127.0.0.1:2379'
resource 'Role'
end
sensu_etcd_replicator 'role_binding_replicator' do
cert '/etc/ssl/fake.pem'
key '/etc/ssl/fake.key'
url 'http://127.0.0.1:2379'
resource 'RoleBinding'
end
sensu_etcd_replicator 'cluster_role_replicator' do
cert '/etc/ssl/fake.pem'
key '/etc/ssl/fake.key'
url 'http://127.0.0.1:2379'
resource 'ClusterRole'
end
sensu_etcd_replicator 'cluster_role_binding_replicator' do
cert '/etc/ssl/fake.pem'
key '/etc/ssl/fake.key'
url 'http://127.0.0.1:2379'
resource 'ClusterRoleBinding'
end
sensu_search 'check-config' do
parameters [
'published:true',
'subscription:linux',
'labelSelector: region == \"us-west-1\"',
]
resource 'core.v2/CheckConfig'
end
sensu_global_config 'custom-web-ui' do
default_preferences(page_size: 50,
theme: 'deuteranopia')
link_policy(allow_list: true,
urls: [
'https://example.com',
'steamapp://34234234',
'//google.com',
'//*.google.com',
'//bob.local',
])
end
sensu_tessen_config 'default' do
opt_out true
end