You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
26
+
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. This should be unique per node.
27
+
The application of the elasticsearch role results in the installation of a node on a host.
27
28
28
29
The simplest configuration therefore consists of:
29
30
@@ -36,12 +37,16 @@ The simplest configuration therefore consists of:
36
37
vars:
37
38
```
38
39
40
+
The above installs a single node 'node1' on the hosts 'localhost'.
41
+
42
+
### Basic Elasticsearch Configuration
43
+
39
44
All Elasticsearch configuration parameters are supported. This is achieved using a configuration map parameter 'es_config' which is serialized into the elasticsearch.yml file.
40
45
The use of a map ensures the Ansible playbook does not need to be updated to reflect new/deprecated/plugin configuration parameters.
41
46
42
47
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.
43
48
44
-
The following illustrates applying configuration parameters to an Elasticsearch instance.
49
+
The following illustrates applying configuration parameters to an Elasticsearch instance. By default, Elasticsearch 2.1.0 is installed.
45
50
46
51
```
47
52
- name: Elasticsearch with custom configuration
@@ -55,17 +60,20 @@ The following illustrates applying configuration parameters to an Elasticsearch
55
60
es_version_lock: false
56
61
es_heap_size: 1g
57
62
```
63
+
`
64
+
The role utilises Elasticsearch version defaults. Multicast is therefore enabled for 1.x and disabled for 2.x (plugin required in 2.x). If using 1.x it is strongly recommended you disable
65
+
multicast and specify the required uni-cast settings for a production environment.
66
+
When not utilizing multicast, the following should be set to ensure a successful cluster forms.
58
67
68
+
*```es_config['http.port']``` - the http port for the node
69
+
*```es_config['transport.tcp.port']``` - the transport port for the node
70
+
*```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)
71
+
*```es_config['network.host']``` - sets both network.bind_host and network.publish_host to the same host value. The network.bind_host setting allows to control the host different network components will bind on.
59
72
73
+
The network.publish_host setting allows to control the host the node will publish itself within the cluster so other nodes will be able to connect to it.
60
74
61
-
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:
62
-
63
-
1. es_config['http.port'] - the http port for the node
64
-
2. es_config['transport.tcp.port'] - the transport port for the node
65
-
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)
66
-
67
-
68
-
If set to true, the ports will be auto defined and node discovery will be performed using multicast.
75
+
See https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html for further details on default binding behaviour and available options.
76
+
The role makes no attempt to enforce the setting of these are requires users to specify them appropriately. IT is recommended master nodes are listed and thus deployed first where possible.
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.
104
+
### Multi Node Server Installations
105
105
106
-
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'
106
+
The application of the elasticsearch role results in the installation of a node on a host. Specifying the role multiple times for a host therefore results in the installation of multiple nodes for the host.
107
107
108
-
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.
108
+
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. Whilst not mandatory, this is
109
+
recommended in any multi node cluster configuration.
@@ -146,17 +144,17 @@ Make sure your hosts are defined in your ```inventory``` file with the appropria
146
144
147
145
Then run it:
148
146
149
-
```
150
-
ansible-playbook -i hosts ./your-playbook.yml
147
+
```ansible-playbook -i hosts ./your-playbook.yml
151
148
```
152
149
153
-
## Configuration
154
-
You can add the role without any customisation and it will by default install Java and Elasticsearch, without any plugins.
150
+
### Additional Configuration
151
+
152
+
Additional parameters to es_config allow the customization of the Java and Elasticsearch versions, in addition to role behaviour. Options include:
155
153
156
154
Following variables affect the versions installed:
157
155
158
-
*```es_major_version``` (e.g. "1.5" )
159
-
*```es_version``` (e.g. "1.5.2")
156
+
*```es_major_version``` (e.g. "1.5" ). Should be consistent with es_version.
157
+
*```es_version``` (e.g. "1.5.2"). For versions > 2.x this must be "2.x".
160
158
*```es_start_service``` (true (default) or false)
161
159
*```es_plugins_reinstall``` (true or false (default) )
162
160
*```es_plugins``` (an array of plugin definitons e.g.:
@@ -166,14 +164,33 @@ Following variables affect the versions installed:
166
164
- plugin: elasticsearch-cloud-aws
167
165
version: 2.5.0
168
166
```
169
-
170
-
*```java_repos``` (an array of repositories to be added to allow java to be installed)
171
-
*```java_packages``` (an array of packages to be installed to get Java installed)
167
+
Earlier examples illustrate the installation of plugins for 2.x. The correct use of this parameter varies depending on the version of Elasticsearch being installed:
168
+
169
+
- 2.x. - For officially supported plugins no version or source delimiter is required. The plugin script will determine the appropriate plugin version based on the target Elasticsearch version.
170
+
For community based plugins include the full path e.g. "lmenezes/elasticsearch-kopf" and the appropriate version for the target version of Elasticsearch.
171
+
- 1.x - Full path and version is required for both community and official plugins e.g. "elasticsearch/marvel"
172
+
173
+
If installing Marvel or Watcher, ensure the license plugin is also specified. Shield configuration is currently not supported but planned for later versions.
174
+
175
+
*```es_user``` - defaults to elasticsearch.
176
+
*```es_group``` - defaults to elasticsearch.
177
+
178
+
By default, each node on a host will be installed to use unique pid, plugin, work, data and log directories. These directories are created, using the instance and host name, beneath default locations ]
179
+
controlled by the following parameters:
180
+
181
+
*```es_pid_dir``` - defaults to "/var/run/elasticsearch".
182
+
*```es_data_dir``` - defaults to "/var/lib/elasticsearch".
183
+
*```es_log_dir``` - defaults to "/var/log/elasticsearch".
184
+
*```es_work_dir``` - defaults to "/tmp/elasticsearch".
185
+
*```es_plugin_dir``` - defaults to "/usr/share/elasticsearch/plugins".
172
186
173
187
## Notes
174
188
175
189
* The role assumes the user/group exists on the server. The elasticsearch packages create the default elasticsearch user. If this needs to be changed, ensure the user exists.
176
190
* The playbook relies on the inventory_name of each host to ensure its directories are unique
177
191
* Systemd scripts are by default installed in addition to init scripts - with the exception of Debian 8. This is pending improvement and currently relies on the user to determine the preferred mechanism.
178
192
* Changing an instance_name for a role application will result in the installation of a new component. The previous component will remain.
179
-
* KitchenCI has been used for testing. This is used to confirm images reach the correct state after a play is first applied.
193
+
* KitchenCI has been used for testing. This is used to confirm images reach the correct state after a play is first applied. We currently test only the latest version of each major release i.e. 1.7.3 and 2.1.0 on
194
+
all supported platforms.
195
+
* The role aims to be idempotent. Running the role multiple times, with no changes, should result in no state change on the server. If the configuration is changed, these will be applied and
Copy file name to clipboardExpand all lines: tasks/checkParameters.yml
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
# Check for mandatory parameters
2
2
3
-
- fail: msg="es_instance_name must be specified"
4
-
when: es_instance_name is not defined
3
+
- fail: msg="es_instance_name must be specified and cannot be blank"
4
+
when: es_instance_name is not defined or es_instance_name == ''
5
5
6
-
- set_fact: multi_cast={{ (es_version | version_compare('2.0', '<') and es_config['discovery.zen.ping.multicast.enabled'] is not defined) or es_config['discovery.zen.ping.multicast.enabled']}}
6
+
- set_fact: multi_cast={{ (es_version | version_compare('2.0', '<') and es_config['discovery.zen.ping.multicast.enabled'] is not defined) or (es_config['discovery.zen.ping.multicast.enabled'] is defined and es_config['discovery.zen.ping.multicast.enabled'])}}
7
7
8
-
- fail: msg="Parameter 'http.port' must be defined when multicast is disabled"
8
+
- debug: msg="WARNING - It is recommended you specify the parameter 'http.port' when multicast is disabled"
9
9
when: not multi_cast and es_config['http.port'] is not defined
10
10
11
-
- fail: msg="Parameter 'transport.tcp.port' must be defined when multicast is disabled"
11
+
- debug: msg="WARNING - It is recommended you specify the parameter 'transport.tcp.port' when multicast is disabled"
12
12
when: not multi_cast and es_config['transport.tcp.port'] is not defined
13
13
14
-
- fail: msg="Parameter 'discovery.zen.ping.unicast.hosts' must be defined when multicast is disabled"
14
+
- debug: msg="WARNING - It is recommended you specify the parameter 'discovery.zen.ping.unicast.hosts' when multicast is disabled"
15
15
when: not multi_cast and es_config['discovery.zen.ping.unicast.hosts'] is not defined
16
16
17
17
#If the user attempts to lock memory they must specify a heap size
failed_when: "'Failed to install' in command_result.stderr"
13
-
changed_when: command_result.rc == 0
14
+
command: "{{es_home}}/bin/plugin install {{ item.plugin }}{% if item.version is defined and item.version != '' %}/{{ item.version }}{% endif %} --silent"
15
+
register: plugin_installed
16
+
failed_when: "'Failed to install' in plugin_installed.stderr"
17
+
changed_when: plugin_installed.rc == 0
14
18
with_items: es_plugins
15
-
when: ( ansible_os_family == 'RedHat' or ansible_os_family == 'Debian' )
19
+
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Debian'
0 commit comments