From 57fa4e5176dfbba9f6d5c89f0d67177164fa9f28 Mon Sep 17 00:00:00 2001 From: pemontto Date: Fri, 18 Oct 2019 16:54:46 +0100 Subject: [PATCH] Add option to enable xpack trial --- defaults/main.yml | 1 + tasks/main.yml | 4 ++++ .../elasticsearch-xpack-activation.yml | 4 ++-- .../elasticsearch-xpack-trial-activation.yml | 18 ++++++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tasks/xpack/security/elasticsearch-xpack-trial-activation.yml diff --git a/defaults/main.yml b/defaults/main.yml index dc674cc..f6f990f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -33,6 +33,7 @@ es_max_threads: 8192 es_max_map_count: 262144 es_allow_downgrades: false es_xpack_features: [] +es_xpack_trial: false #These are used for internal operations performed by ansible. #They do not affect the current configuration es_api_scheme: "http" diff --git a/tasks/main.yml b/tasks/main.yml index 5ef6a03..1e62770 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -90,6 +90,10 @@ include: ./xpack/security/elasticsearch-xpack-activation.yml when: es_start_service and es_enable_xpack and es_xpack_license is defined and es_xpack_license != '' +- name: activate-trial + include: ./xpack/security/elasticsearch-xpack-trial-activation.yml + when: es_start_service and es_enable_xpack and es_xpack_trial + #perform security actions here now elasticsearch is started - name: include xpack/security/elasticsearch-security-native.yml include: ./xpack/security/elasticsearch-security-native.yml diff --git a/tasks/xpack/security/elasticsearch-xpack-activation.yml b/tasks/xpack/security/elasticsearch-xpack-activation.yml index 55e3063..b29f83b 100644 --- a/tasks/xpack/security/elasticsearch-xpack-activation.yml +++ b/tasks/xpack/security/elasticsearch-xpack-activation.yml @@ -17,5 +17,5 @@ license_activated.json.license_status is not defined or license_activated.json.license_status != 'valid' -- debug: - msg: "License: {{ license_activated }}" +- name: License + debug: msg={{ license_activated }} diff --git a/tasks/xpack/security/elasticsearch-xpack-trial-activation.yml b/tasks/xpack/security/elasticsearch-xpack-trial-activation.yml new file mode 100644 index 0000000..b8306c4 --- /dev/null +++ b/tasks/xpack/security/elasticsearch-xpack-trial-activation.yml @@ -0,0 +1,18 @@ +--- +- name: Activate ES trial license (with security authentication) + uri: + method: POST + url: "{{ es_api_uri }}/_{{ 'xpack/' if es_version is version_compare('7.0.0', '<') else '' }}license/start_trial?acknowledge=true" + user: "{{es_api_basic_auth_username | default(omit)}}" + password: "{{es_api_basic_auth_password | default(omit)}}" + return_content: yes + force_basic_auth: yes + status_code: + - 200 + - 403 + validate_certs: "{{ es_validate_certs }}" + register: trial_license_activated + when: es_xpack_trial + +- name: Trial license + debug: msg={{ trial_license_activated }} \ No newline at end of file