Additional tests + support for empty es_config + documentation
This commit is contained in:
parent
e98b74ab28
commit
b2997cc0bc
9 changed files with 101 additions and 63 deletions
140
README.md
140
README.md
|
|
@ -4,8 +4,7 @@ Ansible playbook / roles / tasks for Elasticsearch. Currently it will work on D
|
|||
|
||||
## 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.
|
||||
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.
|
||||
|
||||
|
|
@ -17,23 +16,46 @@ mkdir -p roles
|
|||
ln -s /my/repos/ansible-elasticsearch ./roles/elasticsearch
|
||||
```
|
||||
|
||||
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:
|
||||
Then create your playbook yaml adding the role elasticsearch. By default, the user is only required to specify a unique es_instance_name per role application.
|
||||
|
||||
The simplest configuration therefore consists of:
|
||||
|
||||
```
|
||||
---
|
||||
hosts: my_host
|
||||
- name: Simple Example
|
||||
hosts: localhost
|
||||
roles:
|
||||
- { role: elasticsearch, es_multicast_enabled: true}
|
||||
tasks:
|
||||
- .... your tasks ...
|
||||
- { role: elasticsearch, es_instance_name: "node1" }
|
||||
vars:
|
||||
```
|
||||
|
||||
By default es_multicast_enabled is false and the user is required to specify the following additional parameters:
|
||||
All Elasticsearch configuration parameters are supported. This is achieved using a configuration map parameter 'es_config' which is serialized into the elasticsearch.yml file.
|
||||
The use of a map ensures the Ansible playbook does not need to be updated to reflect new/deprecated/plugin configuration parameters.
|
||||
|
||||
1. es_http_port - the http port for the node
|
||||
2. es_transport_tcp_port - the transport port for the node
|
||||
3. es_unicast_hosts - the unicast discovery list, in the comma separated format "<host>:<port>,<host>:<port>" (typically the clusters dedicated masters)
|
||||
In addition to the es_config map, several other parameters are supported for additional functions e.g. script installation. These can be found in the role's defaults/main.yml file.
|
||||
|
||||
The following illustrates applying configuration parameters to an Elasticsearch instance.
|
||||
|
||||
```
|
||||
- name: Elasticsearch with custom configuration
|
||||
hosts: localhost
|
||||
roles:
|
||||
#expand to all available parameters
|
||||
- { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch/data", es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
|
||||
vars:
|
||||
es_scripts: false
|
||||
es_templates: false
|
||||
es_version_lock: false
|
||||
es_heap_size: 1g
|
||||
```
|
||||
|
||||
|
||||
|
||||
The playbook utilises Elasticsearch version defaults. By default, therefore, multicast is enabled for 1.x. If disabled, the user user is required to specify the following additional parameters:
|
||||
|
||||
1. es_config['http.port'] - the http port for the node
|
||||
2. es_config['transport.tcp.port'] - the transport port for the node
|
||||
3. es_config['discovery.zen.ping.unicast.hosts'] - the unicast discovery list, in the comma separated format "<host>:<port>,<host>:<port>" (typically the clusters dedicated masters)
|
||||
|
||||
|
||||
If set to true, the ports will be auto defined and node discovery will be performed using multicast.
|
||||
|
|
@ -42,65 +64,75 @@ A more complex example:
|
|||
|
||||
```
|
||||
---
|
||||
hosts: localhost
|
||||
roles:
|
||||
- { role: elasticsearch, es_unicast_hosts: "localhost:9301", es_http_port: "9201", es_transport_tcp_port: "9301", es_data_node: false, es_master_node: true, es_m_lock_enabled: true, es_multicast_enabled: false, es_node_name_prefix: "node1_", es_cluster_name: "custom-cluster" }
|
||||
vars:
|
||||
es_scripts: false
|
||||
es_templates: false
|
||||
es_version_lock: false
|
||||
es_m_lock_enabled: true
|
||||
es_start_service: false
|
||||
es_plugins_reinstall: false
|
||||
es_plugins:
|
||||
- plugin: elasticsearch/elasticsearch-cloud-aws
|
||||
version: 2.5.0
|
||||
- plugin: elasticsearch/marvel
|
||||
version: latest
|
||||
- plugin: elasticsearch/license
|
||||
version: latest
|
||||
- plugin: elasticsearch/shield
|
||||
version: latest
|
||||
- plugin: elasticsearch/elasticsearch-support-diagnostics
|
||||
version: latest
|
||||
- plugin: lmenezes/elasticsearch-kopf
|
||||
version: master
|
||||
tasks:
|
||||
- .... your tasks ...
|
||||
- name: Elasticsearch with custom configuration
|
||||
hosts: localhost
|
||||
roles:
|
||||
#expand to all available parameters
|
||||
- { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch/data", es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
|
||||
vars:
|
||||
es_scripts: false
|
||||
es_templates: false
|
||||
es_version_lock: false
|
||||
es_heap_size: 1g
|
||||
es_scripts: false
|
||||
es_templates: false
|
||||
es_version_lock: false
|
||||
es_start_service: false
|
||||
es_plugins_reinstall: false
|
||||
es_plugins:
|
||||
- plugin: elasticsearch/elasticsearch-cloud-aws
|
||||
version: 2.5.0
|
||||
- plugin: elasticsearch/marvel
|
||||
version: latest
|
||||
- plugin: elasticsearch/license
|
||||
version: latest
|
||||
- plugin: elasticsearch/shield
|
||||
version: latest
|
||||
- plugin: elasticsearch/elasticsearch-support-diagnostics
|
||||
version: latest
|
||||
- plugin: lmenezes/elasticsearch-kopf
|
||||
version: master
|
||||
```
|
||||
|
||||
The above example illustrates the ability to control the configuration.
|
||||
The application of a role results in the installation of a node on a host. Multiple roles equates to multiple nodes for a single host.
|
||||
|
||||
The application of a role results in the installation of a node on a host. Multiple roles equates to multiple nodes for a single host. If specifying multiple roles for a host, and thus multiple nodes, the user must:
|
||||
|
||||
1. Provide a es_node_name_prefix. This is used to ensure seperation of data, log, config and init scripts.
|
||||
2. Ensure those playbooks responsible for installing and starting master eligble roles are specified first. These are required for cluster initalization.
|
||||
In any multi node cluster configuration it is recommened the user list the master eligble roles first - especially if these are used a unicast hosts off which other nodes are 'booted'
|
||||
|
||||
An example of a two server deployment, each with 1 node on one server and 2 nodes on another. The first server holds the master and is thus declared first.
|
||||
|
||||
```
|
||||
---
|
||||
hosts: masters
|
||||
roles:
|
||||
- { role: elasticsearch, es_node_name_prefix: "node1_", es_unicast_hosts: "localhost:9300", es_http_port: "9201", es_transport_tcp_port: "9301", es_data_node: true, es_master_node: false, es_m_lock_enabled: true, es_multicast_enabled: false }
|
||||
vars:
|
||||
es_scripts: false
|
||||
es_templates: false
|
||||
es_version_lock: false
|
||||
es_cluster_name: example-cluster
|
||||
m_lock_enabled: false
|
||||
|
||||
- hosts: data_nodes
|
||||
- hosts: master_nodes
|
||||
roles:
|
||||
- { role: elasticsearch, es_data_node: true, es_master_node: false, es_m_lock_enabled: true, es_multicast_enabled: false, es_node_name_prefix: "node1_" }
|
||||
- { role: elasticsearch, es_data_node: true, es_master_node: false, es_m_lock_enabled: true, es_multicast_enabled: false, es_node_name_prefix: "node2_" }
|
||||
# one master per host
|
||||
- { role: elasticsearch, es_instance_name: "node1", es_heap_size: "1g", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9200, transport.tcp.port: 9300, node.data: false, node.master: true, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } }
|
||||
vars:
|
||||
es_scripts: false
|
||||
es_templates: false
|
||||
es_version_lock: false
|
||||
es_cluster_name: example-cluster
|
||||
es_cluster_name: test-cluster
|
||||
m_lock_enabled: true
|
||||
ansible_user: ansible
|
||||
es_plugins:
|
||||
- plugin: elasticsearch/license
|
||||
version: latest
|
||||
|
||||
- hosts: data_nodes
|
||||
roles:
|
||||
# two nodes per host
|
||||
- { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9200, transport.tcp.port: 9300, node.data: true, node.master: false, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } }
|
||||
- { role: elasticsearch, es_instance_name: "node2", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9201, transport.tcp.port: 9301, node.data: true, node.master: false, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } }
|
||||
vars:
|
||||
es_scripts: false
|
||||
es_templates: false
|
||||
es_version_lock: false
|
||||
es_cluster_name: test-cluster
|
||||
m_lock_enabled: false
|
||||
ansible_user: ansible
|
||||
es_plugins:
|
||||
- plugin: elasticsearch/license
|
||||
version: latest
|
||||
```
|
||||
|
||||
Parameters can additionally be assigned to hosts using the inventory file if desired.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue