2015-04-30 09:22:14 +02:00
# ansible-elasticsearch
2015-04-30 09:23:14 +02:00
2015-05-13 13:45:13 +02:00
Ansible playbook / roles / tasks for Elasticsearch. Currently it will work on Debian and RedHat based linux systems.
## Usage
Create your ansible playbook with your own tasks, and include the role elasticsearch.
You will have to have this repository accessible within the context of playbook, e.g.
e.g.
```
cd /my/repos/
git clone git@github .com:elastic/ansible-elasticsearch.git
cd /my/ansible/playbook
mkdir -p roles
ln -s /my/repos/ansible-elasticsearch ./roles/elasticsearch
```
2015-05-13 14:22:04 +02:00
Then create your playbook yaml adding the role elasticsearch and overriding any variables you wish. It can be as simple as this to take all the defaults:
2015-05-13 13:45:13 +02:00
```
---
2015-05-13 14:22:04 +02:00
hosts: my_host
roles:
- elasticsearch
tasks:
- .... your tasks ...
```
or more complex..
```
---
hosts: my_host
roles:
- elasticsearch
2015-05-13 13:45:13 +02:00
vars:
2015-08-04 09:40:43 +02:00
java_debian:
2015-08-04 09:18:50 +02:00
- "openjdk-7-jre-headless"
2015-08-03 21:30:45 +02:00
es_major_version: 1.7
es_version: 1.7.0
2015-05-13 14:22:04 +02:00
es_start_service: false
2015-05-13 13:45:13 +02:00
es_plugins_reinstall: false
es_plugins:
2015-05-26 15:12:19 +02:00
- plugin: elasticsearch/elasticsearch-cloud-aws
2015-05-13 13:45:13 +02:00
version: 2.5.0
2015-05-26 15:12:19 +02:00
- plugin: elasticsearch/marvel
2015-05-13 13:45:13 +02:00
version: latest
2015-05-26 15:12:19 +02:00
- plugin: elasticsearch/license
2015-05-13 13:45:13 +02:00
version: latest
2015-05-26 15:12:19 +02:00
- plugin: elasticsearch/shield
2015-05-13 13:45:13 +02:00
version: latest
2015-05-26 15:12:19 +02:00
- plugin: elasticsearch/elasticsearch-support-diagnostics
2015-05-13 13:45:13 +02:00
version: latest
2015-05-26 15:12:19 +02:00
- plugin: lmenezes/elasticsearch-kopf
version: master
2015-05-13 13:45:13 +02:00
tasks:
- .... your tasks ...
```
2015-05-13 14:22:04 +02:00
Make sure your hosts are defined in your ```hosts` `` file with the appropriate ` ``ansible_ssh_host` ``, ` ``ansible_ssh_user` `` and ` ``ansible_ssh_private_key_file` `` values.
2015-05-13 13:45:13 +02:00
Then run it:
```
ansible-playbook -i hosts ./your-playbook.yml
```
## Configuration
You can add the role without any customisation and it will by default install Java and Elasticsearch, without any plugins.
2015-08-03 21:30:45 +02:00
#### Description of the variables available.
2015-05-13 13:45:13 +02:00
2015-08-03 21:30:45 +02:00
```es_major_version` `` (e.g. ` 1.7` )
Which major version to use. This is also used to define which the repository is used.
```es_version` `` (e.g. ` 1.7.0`)
Which minor version to use.
```es_start_service` `` (true (default) or false)
2015-08-04 09:05:01 +02:00
Should elasticsearch be started after installation?
2015-08-03 21:30:45 +02:00
```es_use_repository` `` (true (default) or false )
Should elasticsearch be installed from a repository or from a url download. If false package will be downloaded from https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch.... You can also specify `es_custom_package_url` with a url to a custom package.
```es_version_lock` `` (true or false (default))
2015-09-14 17:04:47 +02:00
This will lock the elasticsearch version using `yum versionlock` . Only available on RHEL/CentOS. For Debian/Ubuntu see `apt pinning` below.
2015-08-03 21:30:45 +02:00
```es_scripts` `` (true or false (default))
If true you need to supply a files/scripts/ folder with your scripts, inside the role directory. The folder and all files will be copied to `/etc/elasticsearch/scripts` . You can also provide a scripts/ folder at toplevel of your playbook.
```es_plugins_reinstall` `` (true or false (default) )
Schould plugins be reinstalled?
```es_plugins` `` (an array of plugin definitons e.g.:)
2015-05-13 13:45:13 +02:00
```
2015-08-03 21:30:45 +02:00
es_plugins:
- plugin: elasticsearch-cloud-aws
version: 2.5.0
```
2015-08-03 21:37:39 +02:00
`java_debian`
2015-08-03 21:30:45 +02:00
name of the java debian package to use (e.g. `openjdk-7-jre-headless` )
2015-08-03 21:37:39 +02:00
`java_rhel`
2015-05-13 14:24:15 +02:00
2015-08-03 21:30:45 +02:00
name of the java rhel package to use (e.g. `java-1.8.0-openjdk.x86_64` )
2015-09-14 12:17:16 +02:00
## apt pinning
apt pinning is possible using an external role like https://github.com/debops/ansible-apt_preferences.
To use this, add it as another role e.g.
```
cd /my/repos/
git clone git@github .com:debops/ansible-apt_preferences.git
cd /my/ansible/playbook
mkdir -p roles
ln -s /my/repos/ansible-apt_preferences ./roles/apt_preferences
```
then add something like this to your playook:
```
roles:
- apt_preferences
- elasticsearch
vars:
...
apt_preferences_list:
- package: elasticsearch
version: 1.7.0
...
```