forked from sous-chefs/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_configure.rb
113 lines (94 loc) · 4.59 KB
/
resource_configure.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
# Chef Resource for configuring an Elasticsearch node
class ElasticsearchCookbook::ConfigureResource < Chef::Resource::LWRPBase
resource_name :elasticsearch_configure
provides :elasticsearch_configure
actions(:manage, :remove)
default_action :manage
# this is what helps the various resources find each other
attribute(:instance_name, kind_of: String, default: nil)
# if you override one of these, you should probably override them all
attribute(:path_home, kind_of: Hash, default: {
package: '/usr/share/elasticsearch',
tarball: '/usr/local/elasticsearch'
})
attribute(:path_conf, kind_of: Hash, default: {
package: '/etc/elasticsearch',
tarball: '/usr/local/etc/elasticsearch'
})
attribute(:path_data, kind_of: Hash, default: {
package: '/usr/share/elasticsearch',
tarball: '/usr/local/var/data/elasticsearch'
})
attribute(:path_logs, kind_of: Hash, default: {
package: '/var/log/elasticsearch',
tarball: '/usr/local/var/log/elasticsearch'
})
attribute(:path_pid, kind_of: Hash, default: {
package: '/var/run/elasticsearch',
tarball: '/usr/local/var/run'
})
attribute(:path_plugins, kind_of: Hash, default: {
package: '/usr/share/elasticsearch/plugins',
tarball: '/usr/local/elasticsearch/plugins'
})
attribute(:path_bin, kind_of: Hash, default: {
package: '/usr/share/elasticsearch/bin',
tarball: '/usr/local/bin'
})
attribute(:template_elasticsearch_env, kind_of: String, default: 'elasticsearch.in.sh.erb')
attribute(:cookbook_elasticsearch_env, kind_of: String, default: 'elasticsearch')
attribute(:template_elasticsearch_yml, kind_of: String, default: 'elasticsearch.yml.erb')
attribute(:cookbook_elasticsearch_yml, kind_of: String, default: 'elasticsearch')
attribute(:template_logging_yml, kind_of: String, default: 'logging.yml.erb')
attribute(:cookbook_logging_yml, kind_of: String, default: 'elasticsearch')
attribute(:logging, kind_of: Hash, default: {})
attribute(:java_home, kind_of: String, default: nil)
attribute(:startup_sleep_seconds, kind_of: [String, Integer], default: 5)
# Calculations for this are done in the provider, as we can't do them in the
# resource definition. default is 50% of RAM or 31GB, which ever is smaller.
attribute(:allocated_memory, kind_of: String)
attribute(:thread_stack_size, kind_of: String, default: '256k')
attribute(:env_options, kind_of: String, default: '')
attribute(:gc_settings, kind_of: String, default:
<<-CONFIG
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+HeapDumpOnOutOfMemoryError
-XX:+DisableExplicitGC
CONFIG
)
# default user limits
attribute(:memlock_limit, kind_of: String, default: 'unlimited')
attribute(:nofile_limit, kind_of: String, default: '64000')
# These are the default settings. Most of the time, you want to override
# the `configuration` attribute below. If you do override the defaults, you
# must supply ALL needed defaults, and don't use nil as a value in the hash.
attribute(:default_configuration, kind_of: Hash, default: {
# === NAMING
'cluster.name' => 'elasticsearch',
# can't access node.name, so expect to have to set set this
'node.name' => Chef::Config[:node_name],
# if omitted or nil, these will be populated from attributes above
'path.conf' => nil, # see path_conf above
'path.data' => nil, # see path_data above
'path.logs' => nil, # see path_logs above
# Refer to ES documentation on how to configure these to a
# specific node role/type instead of using the defaults
#
# 'node.data' => ?,
# 'node.master' => ?,
'action.destructive_requires_name' => true,
'node.max_local_storage_nodes' => 1,
'discovery.zen.ping.multicast.enabled' => true,
'discovery.zen.minimum_master_nodes' => 1,
'gateway.expected_nodes' => 0,
'http.port' => 9200
})
# These settings are merged with the `default_configuration` attribute,
# allowing you to override and set specific settings. Unless you intend to
# wipe out all default settings, your configuration items should go here.
#
attribute(:configuration, kind_of: Hash, default: {})
end