This code allows you to launch, bootstrap and configure an Ubuntu 12.04 server with Elasticsearch, from scratch.
You need Ruby 1.9 and the Bundler gem. You need to install VirtualBox for Vagrant.
Elasticsearch is installed via Chef Solo integration
from the karmi/cookbook-elasticsearch
cookbook.
You may customize the setup with a configuration and installation file (see instructions below).
Setup:
1/ Install required Rubygems:
bundle install
2/ Launch and provision the virtual machine:
time bundle exec vagrant up
3/ Connect to the box via SSH:
bundle exec vagrant ssh
You should see elasticsearch running on http://33.33.33.10:9200/.
4/ Execute a command via SSH:
bundle exec vagrant ssh -c "service elasticsearch status -v"
5/ To customize the Elasticsearch installation, pass a path to JSON file over-riding the default attributes:
echo '
{
"elasticsearch" : {
"cluster_name" : "elasticsearch_test_in_vagrant",
"index_shards" : 1,
"index_replicas" : 0
}
}' > node.json
NODE_CONFIG=node.json time bundle exec vagrant up
6/ To perform additional commands after the installation, pass a path to file with commands:
echo '
# Install the Tire Rubygem
apt-get install make git libcurl3 libcurl3-gnutls libcurl4-openssl-dev libsqlite3-dev -y
apt-get install redis-server -y
apt-get install ruby1.9.3 -y
update-alternatives --set ruby /usr/bin/ruby1.9.1
gem install bundler --no-rdoc --no-ri
test -d "tire" || git clone git://github.com/karmi/tire.git
chown -R vagrant:staff tire
cd tire
bundle install
' > install.sh
NODE_CONFIG=node.json INSTALL=install.sh time bundle exec vagrant up
7/ After you start the virtual machine, you can update the node configuration and additional commands and re-run the provisioning:
NODE_CONFIG=node.json INSTALL=install.sh time bundle exec vagrant provision
8/ To run a sequence of commands prepared locally, pass it to SSH:
echo '
cd tire
echo "Running Tire tests in '`pwd`'"
echo "Ruby: `ruby -v`"
echo "Java: `java -version 2>&1 | head -1`"
rm -f results.txt
for i in {1..5}
do
echo "-------------------------------------------------------------------------------"
echo "TEST $i"
echo "-------------------------------------------------------------------------------"
time bundle exec rake test
if [ $? == 0 ]; then echo "$i: OK" >> results.txt; else echo "$i: FAIL">> results.txt; fi
done
echo; echo; echo "==============================================================================="
cat results.txt
' > run_tire_tests.sh
cat run_tire_tests.sh | xargs -0 bundle exec vagrant ssh -c