Ansible : Playbook Elasticsearch
The aim of this project is to deploy an Elasticsearch cluster on Vagrant Linux instances.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Prerequisites
What things you need to run this Ansible playbook :
- Vagrant must be installed on your computer
- Update the Vagrant file based on your computer (CPU, memory), if needed
- Update the operating system to deploy in the Vagrant file (default: Ubuntu)
- Download the Ansible requirements:
$ ansible-galaxy install -r requirements.yml
Usage
A good point with Vagrant is that you can create, update and destroy all architecture easily with some commands.
Be aware that you need to be in the Vagrant directory to be able to run the commands.
Deployment
To deploy Elasticsearch on Vagrant instance, just run this command :
$ vagrant up
If everything run as expected, you should be able to list the virtual machine created :
$ vagrant status
Current machine states:
elasticsearch01 running (virtualbox)
elasticsearch02 running (virtualbox)
elasticsearch03 running (virtualbox)
If everything run has expected, you should get the cluster status by this URL : http://10.0.3.121:9200/_cluster/health
Or by this curl command :
$ curl "http://10.0.3.121:9200/_cluster/health?pretty"
{
"cluster_name" : "ELS_DEFAULT_NAME",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
Destroy
To destroy the Vagrant resources created, just run this command :
$ vagrant destroy
How-To
This section list some simple command to use and manage the playbook and the Vagrant hosts.
Update with Ansible
To update the Elasticsearch cluster configuration with Ansible, you just have to run the Ansible playbook elasticsearch.yml with this command :
$ ansible-playbook elasticsearch.yml
Update with Vagrant
To update the Elasticsearch cluster configuration with Vagrant, you just have to run provisioning part of the Vagrant file :
$ vagrant provision
Connect to Vagrant instance
To be able to connect to a Vagrant instance, you should use the CLI which is configured to automatically use the default SSH key :
$ vagrant ssh elasticsearch01
Author
Member of Wikitops : https://www.wikitops.io/
Licence
This project is licensed under the Apache License, Version 2.0. For the full text of the license, see the LICENSE file.