Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 9d9b87e

Browse files
authored
Merge pull request #412 from elastic/6.x_testing
6.x testing - Update tests to work with dynamic es_versions
2 parents 5050d8f + 6361f93 commit 9d9b87e

40 files changed

+377
-122
lines changed

.kitchen.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ platforms:
3939
- pip install jmespath
4040
- pip uninstall -y ansible
4141
use_sudo: false
42-
volume: <%=ENV['ES_XPACK_LICENSE_FILE']%>:/tmp/license.json
42+
volume:
43+
- <%=ENV['ES_XPACK_LICENSE_FILE']%>:/tmp/license.json
44+
- /etc/elasticsearch
4345
- name: ubuntu-16.04
4446
driver_config:
4547
image: dliappis/ubuntu-devopsci:16.04
@@ -51,7 +53,9 @@ platforms:
5153
- pip install jmespath
5254
- pip uninstall -y ansible
5355
use_sudo: false
54-
volume: <%=ENV['ES_XPACK_LICENSE_FILE']%>:/tmp/license.json
56+
volume:
57+
- <%=ENV['ES_XPACK_LICENSE_FILE']%>:/tmp/license.json
58+
- /etc/elasticsearch
5559
run_command: "/sbin/init"
5660
- name: debian-8
5761
driver_config:
@@ -65,7 +69,9 @@ platforms:
6569
- sed -ri 's/^#?UsePAM .*/UsePAM no/' /etc/ssh/sshd_config
6670
- pip install jmespath
6771
- pip uninstall -y ansible
68-
volume: <%=ENV['ES_XPACK_LICENSE_FILE']%>:/tmp/license.json
72+
volume:
73+
- <%=ENV['ES_XPACK_LICENSE_FILE']%>:/tmp/license.json
74+
- /etc/elasticsearch
6975
use_sudo: false
7076
run_command: "/sbin/init"
7177
- name: centos-7
@@ -80,7 +86,9 @@ platforms:
8086
- yum -y remove ansible
8187
- yum clean all
8288
- pip install jmespath
83-
volume: <%=ENV['ES_XPACK_LICENSE_FILE']%>:/tmp/license.json
89+
volume:
90+
- <%=ENV['ES_XPACK_LICENSE_FILE']%>:/tmp/license.json
91+
- /etc/elasticsearch
8492
run_command: "/usr/sbin/init"
8593
privileged: true
8694
use_sudo: false

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source 'https://rubygems.org'
22

3-
gem 'test-kitchen', '1.17.0'
3+
gem 'test-kitchen', '1.20.0'
44
gem 'kitchen-docker', '2.6.0'
5-
gem 'kitchen-ansible', '0.47.3'
6-
gem 'net-ssh', '4.1.0'
5+
gem 'kitchen-ansible', '0.48.1'
6+
gem 'net-ssh', '4.2.0'

Gemfile.lock

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,75 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
artifactory (2.8.2)
5-
kitchen-ansible (0.47.3)
6-
mixlib-shellout (<= 2.2.7)
4+
builder (3.2.3)
5+
erubis (2.7.0)
6+
ffi (1.9.18)
7+
gssapi (1.2.0)
8+
ffi (>= 1.0.1)
9+
gyoku (1.3.1)
10+
builder (>= 2.1.2)
11+
httpclient (2.8.3)
12+
kitchen-ansible (0.48.1)
713
net-ssh (>= 3)
814
test-kitchen (~> 1.4)
915
kitchen-docker (2.6.0)
1016
test-kitchen (>= 1.0.0)
11-
mixlib-install (2.1.12)
12-
artifactory
17+
little-plugger (1.1.4)
18+
logging (2.2.2)
19+
little-plugger (~> 1.1)
20+
multi_json (~> 1.10)
21+
mixlib-install (3.9.0)
1322
mixlib-shellout
1423
mixlib-versioning
1524
thor
16-
mixlib-shellout (2.2.7)
25+
mixlib-shellout (2.3.2)
1726
mixlib-versioning (1.2.2)
27+
multi_json (1.13.1)
1828
net-scp (1.2.1)
1929
net-ssh (>= 2.6.5)
20-
net-ssh (4.1.0)
30+
net-ssh (4.2.0)
2131
net-ssh-gateway (1.3.0)
2232
net-ssh (>= 2.6.5)
23-
safe_yaml (1.0.4)
24-
test-kitchen (1.17.0)
25-
mixlib-install (>= 1.2, < 3.0)
33+
nori (2.6.0)
34+
rubyntlm (0.6.2)
35+
rubyzip (1.2.1)
36+
test-kitchen (1.20.0)
37+
mixlib-install (~> 3.6)
2638
mixlib-shellout (>= 1.2, < 3.0)
2739
net-scp (~> 1.1)
2840
net-ssh (>= 2.9, < 5.0)
2941
net-ssh-gateway (~> 1.2)
30-
safe_yaml (~> 1.0)
3142
thor (~> 0.19, < 0.19.2)
43+
winrm (~> 2.0)
44+
winrm-elevated (~> 1.0)
45+
winrm-fs (~> 1.1.0)
3246
thor (0.19.1)
47+
winrm (2.2.3)
48+
builder (>= 2.1.2)
49+
erubis (~> 2.7)
50+
gssapi (~> 1.2)
51+
gyoku (~> 1.0)
52+
httpclient (~> 2.2, >= 2.2.0.2)
53+
logging (>= 1.6.1, < 3.0)
54+
nori (~> 2.0)
55+
rubyntlm (~> 0.6.0, >= 0.6.1)
56+
winrm-elevated (1.1.0)
57+
winrm (~> 2.0)
58+
winrm-fs (~> 1.0)
59+
winrm-fs (1.1.1)
60+
erubis (~> 2.7)
61+
logging (>= 1.6.1, < 3.0)
62+
rubyzip (~> 1.1)
63+
winrm (~> 2.0)
3364

3465
PLATFORMS
3566
ruby
3667

3768
DEPENDENCIES
38-
kitchen-ansible (= 0.47.3)
69+
kitchen-ansible (= 0.48.1)
3970
kitchen-docker (= 2.6.0)
40-
net-ssh (= 4.1.0)
41-
test-kitchen (= 1.17.0)
71+
net-ssh (= 4.2.0)
72+
test-kitchen (= 1.20.0)
4273

4374
BUNDLED WITH
44-
1.15.3
75+
1.16.1

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# ansible-elasticsearch
22
[![Ansible Galaxy](https://img.shields.io/badge/ansible--galaxy-elastic.elasticsearch-blue.svg)](https://galaxy.ansible.com/elastic/elasticsearch/)
33

4-
**THIS ROLE IS FOR 5.x. FOR 2.x SUPPORT PLEASE USE THE 2.x BRANCH.**
4+
**THIS ROLE IS FOR 6.x, 5.x. FOR 2.x SUPPORT PLEASE USE THE 2.x BRANCH.**
55

66
Ansible role for 5.x Elasticsearch. Currently this works on Debian and RedHat based linux systems. Tested platforms are:
77

88
* Ubuntu 14.04/16.04
99
* Debian 8
1010
* Centos 7
1111

12-
The latest Elasticsearch versions of 5.x are actively tested. **Only Ansible versions > 2.3.2 are supported, as this is currently the only version tested.**
12+
The latest Elasticsearch versions of 6.x are actively tested. **Only Ansible versions > 2.3.2 are supported, as this is currently the only version tested.**
1313

1414
##### Dependency
1515
This role uses the json_query filter which [requires jmespath](https://github.com/ansible/ansible/issues/24319) on the local machine.
@@ -329,7 +329,7 @@ These can either be set to a user declared in the file based realm, with admin p
329329

330330
In addition to es_config, the following parameters allow the customization of the Java and Elasticsearch versions as well as the role behaviour. Options include:
331331

332-
* ```es_major_version``` Should be consistent with es_version. For versions >= 5.0 this must be "5.x".
332+
* ```es_major_version``` Should be consistent with es_version. For versions >= 5.0 and < 6.0 this must be "5.x". For versions >= 6.0 this must be "6.x".
333333
* ```es_version``` (e.g. "5.1.2").
334334
* ```es_api_host``` The host name used for actions requiring HTTP e.g. installing templates. Defaults to "localhost".
335335
* ```es_api_port``` The port used for actions requiring HTTP e.g. installing templates. Defaults to 9200. **CHANGE IF THE HTTP PORT IS NOT 9200**
@@ -396,7 +396,7 @@ To define proxy only for a particular plugin during its installation:
396396
* 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.
397397
* The playbook relies on the inventory_name of each host to ensure its directories are unique
398398
* Changing an instance_name for a role application will result in the installation of a new component. The previous component will remain.
399-
* 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 5.x on
399+
* 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 6.x on
400400
all supported platforms.
401401
* 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
402402
Elasticsearch restarted where required.
@@ -405,7 +405,7 @@ Elasticsearch restarted where required.
405405

406406
## IMPORTANT NOTES RE PLUGIN MANAGEMENT
407407

408-
* If the ES version is changed, all plugins will be removed. Those listed in the playbook will be re-installed. This is behaviour is required in ES 5.x.
408+
* If the ES version is changed, all plugins will be removed. Those listed in the playbook will be re-installed. This is behaviour is required in ES 6.x.
409409
* If no plugins are listed in the playbook for a node, all currently installed plugins will be removed.
410410
* The role supports automatic detection of differences between installed and listed plugins - installing those listed but not installed, and removing those installed but not listed. Should users wish to re-install plugins they should set es_plugins_reinstall to true. This will cause all currently installed plugins to be removed and those listed to be installed.
411411

defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ es_pid_dir: "/var/run/elasticsearch"
2323
es_data_dirs: "/var/lib/elasticsearch"
2424
es_log_dir: "/var/log/elasticsearch"
2525
es_max_open_files: 65536
26-
es_max_threads: 2048
26+
es_max_threads: "{{ 2048 if ( es_version | version_compare('6.0.0', '<')) else 8192 }}"
2727
es_max_map_count: 262144
2828
es_allow_downgrades: false
2929
es_enable_xpack: false

tasks/elasticsearch-plugins.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
ignore_errors: yes
2020
environment:
2121
CONF_DIR: "{{ conf_dir }}"
22+
ES_PATH_CONF: "{{ conf_dir }}"
2223
ES_INCLUDE: "{{ instance_default_file }}"
2324

2425
#if es_plugins_reinstall is set to true we remove ALL plugins
@@ -47,6 +48,7 @@
4748
register: plugin_removed
4849
environment:
4950
CONF_DIR: "{{ conf_dir }}"
51+
ES_PATH_CONF: "{{ conf_dir }}"
5052
ES_INCLUDE: "{{ instance_default_file }}"
5153

5254
- name: Install elasticsearch plugins
@@ -60,6 +62,7 @@
6062
notify: restart elasticsearch
6163
environment:
6264
CONF_DIR: "{{ conf_dir }}"
65+
ES_PATH_CONF: "{{ conf_dir }}"
6366
ES_INCLUDE: "{{ instance_default_file }}"
6467
ES_JAVA_OPTS: "{% if item.proxy_host is defined and item.proxy_host != '' and item.proxy_port is defined and item.proxy_port != ''%} -Dhttp.proxyHost={{ item.proxy_host }} -Dhttp.proxyPort={{ item.proxy_port }} -Dhttps.proxyHost={{ item.proxy_host }} -Dhttps.proxyPort={{ item.proxy_port }} {% elif es_proxy_host is defined and es_proxy_host != '' %} -Dhttp.proxyHost={{ es_proxy_host }} -Dhttp.proxyPort={{ es_proxy_port }} -Dhttps.proxyHost={{ es_proxy_host }} -Dhttps.proxyPort={{ es_proxy_port }} {% endif %}"
6568
until: plugin_installed.rc == 0

tasks/java.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010
yum: name={{ java }} state={{java_state}}
1111
when: ansible_os_family == 'RedHat'
1212

13+
- name: Get the installed java path
14+
shell: "update-alternatives --display java | grep '^/' | awk '{print $1}' | grep 1.8.0"
15+
register: java_full_path
16+
failed_when: False
17+
changed_when: False
18+
when: ansible_os_family == 'RedHat'
19+
20+
- name: correct java version selected
21+
alternatives:
22+
name: java
23+
path: "{{ java_full_path.stdout }}"
24+
link: /usr/bin/java
25+
when: ansible_os_family == 'RedHat' and java_full_path is defined
26+
1327
- name: Refresh java repo
1428
become: yes
1529
apt: update_cache=yes

tasks/xpack/elasticsearch-xpack-install.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
ignore_errors: yes
1111
environment:
1212
CONF_DIR: "{{ conf_dir }}"
13+
ES_PATH_CONF: "{{ conf_dir }}"
1314
ES_INCLUDE: "{{ instance_default_file }}"
1415

1516

@@ -24,6 +25,7 @@
2425
notify: restart elasticsearch
2526
environment:
2627
CONF_DIR: "{{ conf_dir }}"
28+
ES_PATH_CONF: "{{ conf_dir }}"
2729
ES_INCLUDE: "{{ instance_default_file }}"
2830

2931

@@ -42,6 +44,7 @@
4244
notify: restart elasticsearch
4345
environment:
4446
CONF_DIR: "{{ conf_dir }}"
47+
ES_PATH_CONF: "{{ conf_dir }}"
4548
ES_INCLUDE: "{{ instance_default_file }}"
4649

4750
- name: Delete x-pack zip file
@@ -59,5 +62,6 @@
5962
notify: restart elasticsearch
6063
environment:
6164
CONF_DIR: "{{ conf_dir }}"
65+
ES_PATH_CONF: "{{ conf_dir }}"
6266
ES_INCLUDE: "{{ instance_default_file }}"
6367
ES_JAVA_OPTS: "{% if es_proxy_host is defined and es_proxy_host != '' %}-Dhttp.proxyHost={{ es_proxy_host }} -Dhttp.proxyPort={{ es_proxy_port }} -Dhttps.proxyHost={{ es_proxy_host }} -Dhttps.proxyPort={{ es_proxy_port }}{% endif %}"

tasks/xpack/elasticsearch-xpack.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@
1111
- name: Set Plugin Directory Permissions
1212
become: yes
1313
file: state=directory path={{ es_home }}/plugins owner={{ es_user }} group={{ es_group }} recurse=yes
14+
15+
#Make sure elasticsearch.keystore has correct Permissions
16+
- name: Set elasticsearch.keystore Permissions
17+
become: yes
18+
file: state=file path={{ conf_dir }}/elasticsearch.keystore owner={{ es_user }} group={{ es_group }}
19+
when: es_enable_xpack and "security" in es_xpack_features and (es_version | version_compare('6.0.0', '>'))

tasks/xpack/security/elasticsearch-security-file.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
when: manage_file_users
2222
environment:
2323
CONF_DIR: "{{ conf_dir }}"
24+
ES_PATH_CONF: "{{ conf_dir }}"
2425
ES_HOME: "{{es_home}}"
2526

2627
- set_fact: users_to_add={{ es_users.file.keys() | difference (current_file_users.stdout_lines) }}
@@ -36,6 +37,7 @@
3637
no_log: True
3738
environment:
3839
CONF_DIR: "{{ conf_dir }}"
40+
ES_PATH_CONF: "{{ conf_dir }}"
3941
ES_HOME: "{{es_home}}"
4042

4143
#Set passwords for all users declared - Required as the useradd will not change existing user passwords
@@ -50,6 +52,7 @@
5052
no_log: True
5153
environment:
5254
CONF_DIR: "{{ conf_dir }}"
55+
ES_PATH_CONF: "{{ conf_dir }}"
5356
ES_HOME: "{{es_home}}"
5457

5558
- set_fact: users_roles={{es_users.file | extract_role_users () }}

0 commit comments

Comments
 (0)