Abstract 6.3 changes into a separate task to reduce all of the jinja one
liner complexity Set ES_PATH_CONF when installing so upgrading from 6.2 to 6.3 works as expected
This commit is contained in:
parent
715bd8591e
commit
bbc5e0603d
9 changed files with 52 additions and 13 deletions
|
|
@ -21,9 +21,7 @@ provisioner:
|
|||
extra_vars:
|
||||
es_major_version: "<%= ENV['VERSION'] %>"
|
||||
<% if ENV['VERSION'] == '5.x' %>
|
||||
es_version: '5.6.9'
|
||||
es_package_name: 'elasticsearch'
|
||||
es_use_snapshot_release: false
|
||||
es_version: '5.6.10'
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
|||
35
tasks/compatibility-variables.yml
Normal file
35
tasks/compatibility-variables.yml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
|
||||
# It is possible to set these are defaults with messy jinja templating one liners however:
|
||||
# 1. That is really hard to read and debug
|
||||
# 2. When running multiple plays with the same role the defaults are not re-evaluated. An example of this
|
||||
# can be seen in our the https://github.com/elastic/ansible-elasticsearch/blob/master/test/integration/xpack.yml
|
||||
# integration test and in the Multi Node server documentation examples https://github.com/elastic/ansible-elasticsearch/blob/master/test/integration/xpack.yml
|
||||
|
||||
- name: Set the defaults here otherwise they can't be overriden in the same play if the role is called twice
|
||||
set_fact:
|
||||
es_open_xpack: true
|
||||
es_install_xpack: false
|
||||
es_repo_name: "{{ es_major_version }}"
|
||||
es_xpack_users_command: "elasticsearch-users"
|
||||
|
||||
- name: Detect if es_version is before X-Pack was open and included
|
||||
set_fact:
|
||||
es_open_xpack: false
|
||||
when: "es_version | version_compare('6.3.0', '<')"
|
||||
|
||||
- name: If this is an older version we need to install X-Pack as a plugin and use a differet users command
|
||||
set_fact:
|
||||
es_install_xpack: true
|
||||
es_xpack_users_command: "x-pack/users"
|
||||
when:
|
||||
- not es_open_xpack
|
||||
- es_enable_xpack
|
||||
|
||||
- name: Use the oss repo and package if xpack is not being used
|
||||
set_fact:
|
||||
es_repo_name: "{{ 'oss-' + es_major_version }}"
|
||||
es_package_name: "elasticsearch-oss"
|
||||
when:
|
||||
- es_open_xpack
|
||||
- not es_enable_xpack
|
||||
|
|
@ -36,6 +36,8 @@
|
|||
when: es_use_repository
|
||||
register: debian_elasticsearch_install_from_repo
|
||||
notify: restart elasticsearch
|
||||
environment:
|
||||
ES_PATH_CONF: "/etc/elasticsearch"
|
||||
|
||||
- name: Debian - Include versionlock
|
||||
include: elasticsearch-Debian-version-lock.yml
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
until: redhat_elasticsearch_install_from_repo.rc == 0
|
||||
retries: 5
|
||||
delay: 10
|
||||
environment:
|
||||
ES_PATH_CONF: "/etc/elasticsearch"
|
||||
|
||||
- name: RedHat - Install Elasticsearch from url
|
||||
become: yes
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@
|
|||
tags:
|
||||
- always
|
||||
|
||||
- name: set compatibility variables
|
||||
include: compatibility-variables.yml
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: check-set-parameters
|
||||
include: elasticsearch-parameters.yml
|
||||
tags:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
- name: Remove Users
|
||||
become: yes
|
||||
command: >
|
||||
{{es_home}}/bin/x-pack/users userdel {{item}}
|
||||
{{es_home}}/bin/{{es_xpack_users_command}} userdel {{item}}
|
||||
with_items: "{{users_to_remove | default([])}}"
|
||||
when: manage_file_users
|
||||
environment:
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
- name: Add Users
|
||||
become: yes
|
||||
command: >
|
||||
{{es_home}}/bin/x-pack/users useradd {{item}} -p {{es_users.file[item].password}}
|
||||
{{es_home}}/bin/{{es_xpack_users_command}} useradd {{item}} -p {{es_users.file[item].password}}
|
||||
with_items: "{{ users_to_add | default([]) }}"
|
||||
when: manage_file_users
|
||||
no_log: True
|
||||
|
|
@ -47,12 +47,12 @@
|
|||
- name: Set User Passwords
|
||||
become: yes
|
||||
command: >
|
||||
{{es_home}}/bin/x-pack/users passwd {{ item }} -p {{es_users.file[item].password}}
|
||||
{{es_home}}/bin/{{es_xpack_users_command}} passwd {{ item }} -p {{es_users.file[item].password}}
|
||||
with_items: "{{ es_users.file.keys() | default([]) }}"
|
||||
when: manage_file_users
|
||||
#Currently no easy way to figure out if the password has changed or to know what it currently is so we can skip.
|
||||
changed_when: False
|
||||
no_log: True
|
||||
no_log: False
|
||||
environment:
|
||||
CONF_DIR: "{{ conf_dir }}"
|
||||
ES_PATH_CONF: "{{ conf_dir }}"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
- name: create the keystore if it doesn't exist yet
|
||||
command: >
|
||||
{{es_home}}/bin/elasticsearch-keystore create
|
||||
creates: "{{ conf_dir }}/elasticsearch.keystore"
|
||||
args:
|
||||
creates: "{{ conf_dir }}/elasticsearch.keystore"
|
||||
environment:
|
||||
ES_PATH_CONF: "{{ conf_dir }}"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
vars:
|
||||
es_heap_size: "1g"
|
||||
es_templates: true
|
||||
es_version: "{{ '6.2.4' if es_major_version == '6.x' else '5.6.6' }}" # This is set to an older version than the current default to force an upgrade
|
||||
es_version: "{{ '6.2.4' if es_major_version == '6.x' else '5.6.9' }}" # This is set to an older version than the current default to force an upgrade
|
||||
es_enable_xpack: true
|
||||
es_xpack_license: "{{ lookup('file', '/tmp/license.json') }}"
|
||||
es_plugins:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,3 @@ init_script: "/etc/init.d/elasticsearch"
|
|||
#add supported features here
|
||||
supported_xpack_features: ["alerting","monitoring","graph","security"]
|
||||
reserved_xpack_users: ["elastic","kibana","logstash_system"]
|
||||
|
||||
# X-Pack used to be installed as a plugin. For versions after 6.3 we don't need to install it anymore
|
||||
es_install_xpack: "{{ true if ( es_version | version_compare('6.3.0', '<')) else false }}"
|
||||
es_repo_name: "{{ 'oss-' + es_major_version if (( es_version | version_compare('6.3.0', '>=')) and not es_enable_xpack ) else es_major_version }}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue