forked from sous-chefs/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
214 lines (189 loc) · 6.66 KB
/
Vagrantfile
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
# Launch and provision multiple Linux distributions with Vagrant <http://vagrantup.com>
#
# Support:
#
# * precise64: Ubuntu 12.04 (Precise) 64 bit (primary box)
# * lucid32: Ubuntu 10.04 (Lucid) 32 bit
# * lucid64: Ubuntu 10.04 (Lucid) 64 bit
# * centos6: CentOS 6 32 bit
#
# See:
#
# $ vagrant status
#
# The virtual machines are automatically provisioned upon startup with Chef-Solo
# <http://vagrantup.com/v1/docs/provisioners/chef_solo.html>.
#
begin
require 'active_support/core_ext/hash/deep_merge'
rescue LoadError => e
STDERR.puts '', "[!] ERROR -- Please install ActiveSupport (gem install activesupport)", '-'*80, ''
raise e
end
# Automatically install and mount cookbooks from Berksfile
#
require 'berkshelf/vagrant'
distributions = {
:precise64 => {
:url => 'http://files.vagrantup.com/precise64.box',
:run_list => %w| apt vim java monit elasticsearch elasticsearch::plugins elasticsearch::proxy elasticsearch::aws elasticsearch::data elasticsearch::monit elasticsearch::test |,
:ip => '33.33.33.10',
:primary => true,
:node => {
:elasticsearch => {
:path => {
:data => %w| /usr/local/var/data/elasticsearch/disk1 /usr/local/var/data/elasticsearch/disk2 |
},
:data => {
:devices => {
"/dev/sdb" => {
:file_system => "ext3",
:mount_options => "rw,user",
:mount_path => "/usr/local/var/data/elasticsearch/disk1",
:format_command => "mkfs.ext3 -F",
:fs_check_command => "dumpe2fs"
},
"/dev/sdc" => {
:file_system => "ext3",
:mount_options => "rw,user",
:mount_path => "/usr/local/var/data/elasticsearch/disk2",
:format_command => "mkfs.ext3 -F",
:fs_check_command => "dumpe2fs"
}
}
}
}
}
},
:lucid64 => {
:url => 'http://files.vagrantup.com/lucid64.box',
:run_list => %w| apt vim java monit elasticsearch elasticsearch::proxy elasticsearch::monit |,
:ip => '33.33.33.10',
:primary => false,
:node => {}
},
:lucid32 => {
:url => 'http://files.vagrantup.com/lucid32.box',
:run_list => %w| apt vim java monit elasticsearch elasticsearch::proxy elasticsearch::monit |,
:ip => '33.33.33.11',
:primary => false,
:node => {}
},
:centos6 => {
# Note: Monit cookbook broken on CentOS
:url => 'https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-centos-6.3.box',
:run_list => %w| yum::epel vim java elasticsearch elasticsearch::proxy elasticsearch::data elasticsearch::test |,
:ip => '33.33.33.12',
:primary => false,
:node => {
:java => {
:install_flavor => "openjdk",
:jdk_version => "7"
},
:elasticsearch => {
:path => {
:data => "/usr/local/var/data/elasticsearch/disk1"
},
:data => {
:devices => {
"/dev/sdb" => {
:file_system => "ext3",
:mount_options => "rw,user",
:mount_path => "/usr/local/var/data/elasticsearch/disk1",
:format_command => "mkfs.ext3 -F",
:fs_check_command => "dumpe2fs"
}
}
},
:nginx => {
:user => 'nginx'
}
}
}
}
}
node_config = {
:elasticsearch => {
:cluster => { :name => "elasticsearch_vagrant" },
:plugins => {
'karmi/elasticsearch-paramedic' => {}
},
:limits => {
:nofile => 1024,
:memlock => 512
},
:bootstrap => {
:mlockall => false
},
:logging => {
:discovery => 'TRACE',
'index.indexing.slowlog' => 'INFO, index_indexing_slow_log_file'
},
:nginx => {
:user => 'www-data',
:users => [{ username: 'USERNAME', password: 'PASSWORD' }]
},
# For testing flat attributes:
"index.search.slowlog.threshold.query.trace" => "1ms",
# For testing deep attributes:
:discovery => { :zen => { :ping => { :timeout => "9s" } } },
# For testing custom configuration
:custom_config => {
'threadpool.index.type' => 'fixed',
'threadpool.index.size' => '2'
}
}
}
Vagrant::Config.run do |config|
distributions.each_pair do |name, options|
config.vm.define name, :options => options[:primary] do |box_config|
box_config.vm.box = name.to_s
box_config.vm.box_url = options[:url]
box_config.vm.host_name = name.to_s
box_config.vm.network :hostonly, options[:ip]
# Box customizations
#
# 1. Limit memory to 512 MB
#
box_config.vm.customize ["modifyvm", :id, "--memory", 512]
#
# 2. Create additional disks
#
if name == :precise64 or name == :centos6
disk1, disk2 = "tmp/disk-#{Time.now.to_f}.vdi", "tmp/disk-#{Time.now.to_f}.vdi"
box_config.vm.customize ["createhd", "--filename", disk1, "--size", 250]
box_config.vm.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1,"--type", "hdd", "--medium", disk1]
box_config.vm.customize ["createhd", "--filename", disk2, "--size", 250]
box_config.vm.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 2,"--type", "hdd", "--medium", disk2]
end
# Update packages on the machine
#
config.vm.provision :shell do |shell|
shell.inline = %Q{
which apt-get > /dev/null 2>&1 && apt-get update --quiet --yes && apt-get install curl --quiet --yes
which yum > /dev/null 2>&1 && yum update -y && yum install curl -y
}
end if ENV['UPDATE']
# Install latest Chef on the machine
#
config.vm.provision :shell do |shell|
version = ENV['CHEF'].match(/^\d+/) ? ENV['CHEF'] : nil
shell.inline = %Q{
which apt-get > /dev/null 2>&1 && apt-get install curl --quiet --yes
which yum > /dev/null 2>&1 && yum install curl -y
test -d "/opt/chef" || curl -# -L http://www.opscode.com/chef/install.sh | sudo bash -s -- #{version ? "-v #{version}" : ''}
/opt/chef/embedded/bin/gem list pry | grep pry || /opt/chef/embedded/bin/gem install pry --no-ri --no-rdoc
}
end if ENV['CHEF']
# Provision the machine with Chef Solo
#
box_config.vm.provision :chef_solo do |chef|
chef.data_bags_path = './tmp/data_bags'
chef.provisioning_path = '/etc/vagrant-chef'
chef.log_level = :debug
chef.run_list = options[:run_list]
chef.json = node_config.deep_merge(options[:node])
end
end
end
end