0x0i.elasticsearch

Ansible Role: Elasticsearch
Table of Contents
- Supported Platforms
- Requirements
- Role Variables
- Dependencies
- Example Playbook
- License
- Author Information
This Ansible role installs and configures Elasticsearch, which is a search and analytics engine that works in real-time.
Supported Platforms:
* Debian
* Redhat (CentOS/Fedora)
* Ubuntu
Requirements
You need the unzip/gtar utility installed on the target machine. Check the ansible unarchive module notes for more details.
Role Variables
Variables are organized by the following stages of software and machine setup:
- install
- config
- launch
- uninstall
Install
You can install elasticsearch using operating system package managers (like apt or yum) or by using compressed files (.tar or .zip) that you download.
You can customize the following variables to control the installation process:
elasticsearch_user: <service-user-name> (default: elasticsearch)
- This is the user and group for running
elasticsearchsafely.
install_type: <package | archive> (default: archive)
- package: This uses the package managers of Debian and Redhat. It installs Elasticsearch from their repositories. The installation path is determined by the package manager.
- archive: This allows you to install from compressed files (both tar and zip). You can get these files from the official download/releases site.
install_dir: </path/to/installation/dir> (default: /opt/elasticsearch)
- The target path where
elasticsearchbinaries will be placed.
archive_url: <path-or-url-to-archive> (default: see defaults/main.yml)
- The URL for the compressed archive containing
elasticsearchbinaries. You can find official versions here.
package_url: <path-or-url-to-package> (default: see defaults/main.yml)
- The URL for a Debian or RPM package containing
elasticsearch.
config_dir: </path/to/configuration/dir> (default: /opt/elasticsearch/config)
- Path for configuration files.
Config
Configuration for elasticsearch is done through these files:
elasticsearch.yml: for general configuration.jvm.options: for JVM settings.log4j2.properties: for logging settings.
You can manage these files using the following variables:
managed_configs: <list of configs to manage> (default: see defaults/main.yml)
- List of configuration files to manage.
config: <hash-of-elasticsearch-settings> default: {}
- Settings specific to a node.
jvm_options: <list-of-dicts> default: []
- To set JVM options, use the jvm.options file.
log4j_properties: <list-of-dicts> default: []
- Settings for logging using Apache log4j 2.
Launch
To run the elasticsearch service, we use the systemd tool.
You can customize the service properties using:
extra_run_args: <elasticsearch-cli-options> (default: [])
- Command-line arguments for running the service.
custom_unit_properties: <hash-of-systemd-service-settings> (default: [])
- Customize systemd service unit properties.
Uninstall
You can uninstall and clean up the installation with:
perform_uninstall: <true | false> (default: false)
- Set to
trueto uninstall and remove Elasticsearch.
Dependencies
- 0x0i.systemd
Example Playbook
Basic example:
- hosts: all
roles:
- role: 0x0I.elasticsearch
Install a specific version of Elasticsearch using a package:
- hosts: legacy-ES-cluster
roles:
- role: 0x0I.elasticsearch
vars:
install_type: package
package_url: https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.0.0/elasticsearch-2.0.0.rpm
Provision a hybrid master/data node with custom paths:
- hosts: test-elasticsearch
roles:
- role: 0x0I.elasticsearch
vars:
managed_configs: ['elasticsearch_config']
config:
cluster.name: example-cluster
node.master: true
node.data: true
path:
data: /mnt/data/elasticsearch
logs: /mnt/logs/elasticsearch
Adjust JVM settings and enable verbose logging:
- hosts: elasticsearch
roles:
- role: 0x0I.elasticsearch
vars:
managed_configs: ['jvm_options', 'log4j2_properties']
jvm_options:
- comment: adjust the min and max JVM heap size
arguments:
- '-Xms16g'
- '-Xmx16g'
log4j2_properties:
- comment: log action execution errors
settings:
- logger.action.name: org.elasticsearch.action
logger.action.level: debug
License
MIT
Author Information
This role was created in 2019 by O1.IO.
Elasticsearch, a real-time distributed search and analytics engine
ansible-galaxy install 0x0i.elasticsearch