forked from lusis/chef-logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.rb
60 lines (49 loc) · 1.35 KB
/
server.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
# Encoding: utf-8
#
# Author:: John E. Vincent
# Author:: Bryan W. Berry (<[email protected]>)
# Copyright 2012, John E. Vincent
# Copyright 2012, Bryan W. Berry
# License: Apache 2.0
# Cookbook Name:: logstash
# Recipe:: server
#
#
# install logstash 'server'
name = 'server'
Chef::Application.fatal!("attribute hash node['logstash']['instance']['#{name}'] must exist.") if node['logstash']['instance'][name].nil?
# these should all default correctly. listing out for example.
logstash_instance name do
action :create
end
# services are hard! Let's go LWRP'ing. FIREBALL! FIREBALL! FIREBALL!
logstash_service name do
action [:enable]
end
my_templates = node['logstash']['instance'][name]['config_templates']
if my_templates.nil?
my_templates = {
'input_syslog' => 'config/input_syslog.conf.erb',
'output_stdout' => 'config/output_stdout.conf.erb',
'output_elasticsearch' => 'config/output_elasticsearch.conf.erb'
}
end
logstash_config name do
templates my_templates
action [:create]
variables(
elasticsearch_embedded: true
)
notifies :restart, "logstash_service[#{name}]"
end
# ^ see `.kitchen.yml` for example attributes to configure templates.
logstash_plugins 'contrib' do
instance name
action [:create]
end
logstash_pattern name do
action [:create]
end
logstash_curator 'server' do
action [:create]
end