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

Commit cab03ec

Browse files
authored
xpack features refactoring (#653)
- rename es_enable_xpack variable to oss_version this variable name should be more explicit and consistent with the xpack changes made in 6.3 es_enable_xpack can still be used but is deprecated and will be removed in a later version. - remove es_xpack-features variables this variable was not working anymore since 6.3 [0] [0]: #608
1 parent c125428 commit cab03ec

14 files changed

+31
-74
lines changed

README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,6 @@ ansible-playbook -i hosts ./your-playbook.yml
288288

289289
### Installing X-Pack Features
290290

291-
X-Pack features, such as Security, are supported.
292-
293-
The parameter `es_xpack_features` allows to list xpack features to install (example: `["alerting","monitoring","graph","security","ml"]`).
294-
When the list is empty, it installs all features available with the current licence.
295-
296291
* ```es_role_mapping``` Role mappings file declared as yml as described [here](https://www.elastic.co/guide/en/x-pack/current/mapping-roles.html)
297292

298293

@@ -400,7 +395,7 @@ These can either be set to a user declared in the file based realm, with admin p
400395

401396
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:
402397

403-
* ```es_enable_xpack``` Default `true`. Setting this to `false` will install the oss release of elasticsearch
398+
* ```oss_version``` Default `false`. Setting this to `true` will install the oss release of elasticsearch
404399
* `es_xpack_trial` Default `false`. Setting this to `true` will start the 30-day trail once the cluster starts.
405400
* ```es_version``` (e.g. "7.7.1").
406401
* ```es_api_host``` The host name used for actions requiring HTTP e.g. installing templates. Defaults to "localhost".

defaults/main.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
es_version: "7.7.1"
33
es_use_snapshot_release: false
4-
es_enable_xpack: true
4+
oss_version: false
55
es_package_name: "elasticsearch"
66
es_version_lock: false
77
es_use_repository: true
@@ -33,7 +33,6 @@ es_action_auto_create_index: true
3333
es_max_open_files: 65536
3434
es_max_map_count: 262144
3535
es_allow_downgrades: false
36-
es_xpack_features: []
3736
es_xpack_trial: false
3837
#These are used for internal operations performed by ansible.
3938
#They do not affect the current configuration

tasks/compatibility-variables.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
# 2. When running multiple plays with the same role the defaults are not re-evaluated. An example of this
66
# can be seen in our the https://github.com/elastic/ansible-elasticsearch/blob/master/test/integration/xpack.yml
77
# integration test and in the Multi Node server documentation examples https://github.com/elastic/ansible-elasticsearch/blob/master/test/integration/xpack.yml
8+
- name: Set backward compatibility for deprecated es_enable_xpack variable
9+
when: es_enable_xpack is defined and not es_enable_xpack
10+
block:
11+
- name: Set fact oss_version when using es_enable_xpack
12+
set_fact: oss_version=true
13+
- name: Warn about deprecated es_enable_xpack variable
14+
debug:
15+
msg: "WARNING: es_enable_xpack variable is now deprecated. You should use oss_version instead"
816

917
- name: Set the defaults here otherwise they can't be overriden in the same play if the role is called twice
1018
set_fact:
@@ -14,15 +22,15 @@
1422
es_other_repo_name: "{{ 'oss-' + es_major_version }}"
1523
es_other_apt_url: "deb {{ es_repo_base }}/packages/{{ 'oss-' + es_major_version }}/apt stable main"
1624

17-
- name: Use the oss repo and package if xpack is not being used
25+
- name: Use the oss repo and package
1826
set_fact:
1927
es_repo_name: "{{ 'oss-' + es_major_version }}"
2028
es_other_repo_name: "{{ es_major_version }}"
2129
es_other_apt_url: "deb {{ es_repo_base }}/packages/{{ es_major_version }}/apt stable main"
2230
es_package_name: "elasticsearch-oss"
2331
es_other_package_name: "elasticsearch"
2432
when:
25-
- not es_enable_xpack
33+
- oss_version
2634

2735
- name: Set the URL scheme to https if SSL/TLS is enabled
2836
set_fact:

tasks/elasticsearch-parameters.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Check for mandatory parameters
22

3+
- name: Warn about deprecated es_xpack_features variable
4+
debug:
5+
msg: "WARNING: es_xpack_features variable is now deprecated. All feature are now enabled by default"
6+
when: es_xpack_features is defined and not oss_version
7+
38
- name: fail when es_proxy_port is not defined or is blank
49
fail: msg="es_proxy_port must be specified and cannot be blank when es_proxy_host is defined"
510
when: (es_proxy_port is not defined or es_proxy_port == '') and (es_proxy_host is defined and es_proxy_host != '')
@@ -13,8 +18,8 @@
1318
- name: fail when api credentials are not declared when using security
1419
fail: msg="Enabling security requires an es_api_basic_auth_username and es_api_basic_auth_password to be provided to allow cluster operations"
1520
when:
16-
- es_enable_xpack and "security" in es_xpack_features
17-
- es_api_basic_auth_username is not defined
21+
- not oss_version
22+
- es_api_basic_auth_username is defined
1823
- es_api_basic_auth_password is not defined
1924

2025
- name: fail when ssl enabled without defining a key and certificate
@@ -38,4 +43,3 @@
3843

3944
- name: set fact use_system_d
4045
set_fact: use_system_d={{(ansible_distribution == 'Debian' and ansible_distribution_version is version('8', '>=')) or (ansible_distribution in ['RedHat','CentOS'] and ansible_distribution_version is version('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('15', '>=')) }}
41-

tasks/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
set_fact: manage_native_realm=true
7979
when:
8080
- es_start_service
81-
- es_enable_xpack
81+
- not oss_version
8282
- (es_users is defined and es_users.native is defined) or (es_roles is defined and es_roles.native is defined)
8383

8484
# If playbook runs too fast, Native commands could fail as the Native Realm is not yet up
@@ -88,11 +88,11 @@
8888

8989
- name: activate-license
9090
include: ./xpack/security/elasticsearch-xpack-activation.yml
91-
when: es_start_service and es_enable_xpack and es_xpack_license is defined and es_xpack_license != ''
91+
when: es_start_service and not oss_version and es_xpack_license is defined and es_xpack_license != ''
9292

9393
- name: activate-trial
9494
include: ./xpack/security/elasticsearch-xpack-trial-activation.yml
95-
when: es_start_service and es_enable_xpack and es_xpack_trial
95+
when: es_start_service and not oss_version and es_xpack_trial
9696

9797
#perform security actions here now elasticsearch is started
9898
- name: include xpack/security/elasticsearch-security-native.yml

tasks/xpack/elasticsearch-xpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#Security configuration
44
- name: include security/elasticsearch-security.yml
55
include: security/elasticsearch-security.yml
6-
when: es_enable_xpack
6+
when: not oss_version
77

88
#Make sure elasticsearch.keystore has correct Permissions
99
- name: Set elasticsearch.keystore Permissions

templates/elasticsearch.yml.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ action.auto_create_index: false
3131
action.auto_create_index: {{ es_action_auto_create_index }}
3232
{% endif %}
3333

34-
{% if es_enable_xpack and es_api_basic_auth_username is defined and es_api_basic_auth_password is defined %}
34+
{% if not oss_version and es_api_basic_auth_username is defined and es_api_basic_auth_password is defined %}
3535
xpack.security.enabled: true
3636

3737
{% if es_enable_transport_ssl and es_enable_auto_ssl_configuration %}

test/integration/helpers/serverspec/shared_spec.rb

+2-32
Original file line numberDiff line numberDiff line change
@@ -44,43 +44,13 @@
4444
end
4545
end
4646
describe 'xpack checks' do
47-
if vars['es_enable_xpack']
48-
it 'should be be running the xpack version' do
47+
if not vars['oss_version']
48+
it 'should be be running the basic version' do
4949
expect(curl_json("#{es_api_url}/_xpack", username=username, password=password)['tagline']).to eq('You know, for X')
5050
end
5151
it 'xpack should be activated' do
5252
expect(curl_json("#{es_api_url}/_license", username=username, password=password)['license']['status']).to eq('active')
5353
end
54-
if vars.key?('es_xpack_features')
55-
curl_json("#{es_api_url}/_xpack", username=username, password=password)['features'].each do |feature,values|
56-
enabled = vars['es_xpack_features'].include? feature
57-
status = if enabled then 'enabled' else 'disabled' end
58-
it "the xpack feature '#{feature}' to be #{status}" do
59-
expect(values['enabled'] = enabled)
60-
end
61-
end
62-
else
63-
features.each do |feature, status|
64-
feature_available = curl_json("#{es_api_url}/_xpack", username=username, password=password)['features'][feature]['available']
65-
if feature_available == "true"
66-
status = "available"
67-
else
68-
status = "unavailable"
69-
end
70-
it "the xpack feature '#{feature}' to be #{status}" do
71-
expect(feature_available = status['available'])
72-
end
73-
feature_enabled = curl_json("#{es_api_url}/_xpack", username=username, password=password)['features'][feature]['enabled']
74-
if feature_enabled == "true"
75-
status = "enabled"
76-
else
77-
status = "disabled"
78-
end
79-
it "the xpack feature '#{feature}' to be #{status}" do
80-
expect(feature_available = status['enabled'])
81-
end
82-
end
83-
end
8454
end
8555
end
8656
describe user(vars['es_user']) do

test/integration/issue-test.yml

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
es_heap_size: "1g"
1818
es_plugins:
1919
- plugin: ingest-attachment
20-
es_xpack_features:
21-
- security
22-
- alerting
2320
es_api_basic_auth_username: elastic
2421
es_api_basic_auth_password: changeme
2522
es_users:

test/integration/oss-to-xpack-upgrade.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- elasticsearch
88
vars:
99
es_version: "{{ '7.0.0' if es_major_version == '7.x' else '6.7.1' }}" # This is set to an older version than the current default to force an upgrade
10-
es_enable_xpack: false
10+
oss_version: true
1111
es_heap_size: "1g"
1212

1313
- name: Standard test for single node setup. Tests idempotence.
@@ -17,9 +17,5 @@
1717
roles:
1818
- elasticsearch
1919
vars:
20-
es_enable_xpack: true
20+
oss_version: false
2121
es_heap_size: "1g"
22-
es_xpack_features:
23-
- monitoring
24-
- graph
25-
- ml

test/integration/oss-upgrade.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- elasticsearch
88
vars:
99
es_version: "{{ '7.0.0' if es_major_version == '7.x' else '6.7.1' }}" # This is set to an older version than the current default to force an upgrade
10-
es_enable_xpack: false
10+
oss_version: true
1111
es_heap_size: "1g"
1212

1313
- name: Standard test for single node setup. Tests idempotence.
@@ -17,5 +17,5 @@
1717
roles:
1818
- elasticsearch
1919
vars:
20-
es_enable_xpack: false
20+
oss_version: true
2121
es_heap_size: "1g"

test/integration/oss.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
roles:
77
- elasticsearch
88
vars:
9-
es_enable_xpack: false
9+
oss_version: true
1010
es_heap_size: "1g"
1111
es_plugins:
1212
- plugin: ingest-attachment

test/integration/xpack-upgrade-trial.yml

-6
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
es_xpack_trial: true
2525
es_plugins:
2626
- plugin: ingest-attachment
27-
es_xpack_features:
28-
- security
29-
- alerting
3027
es_api_basic_auth_username: elastic
3128
es_api_basic_auth_password: changeme
3229
es_api_sleep: 5
@@ -140,9 +137,6 @@
140137
es_xpack_trial: false
141138
es_plugins:
142139
- plugin: ingest-attachment
143-
es_xpack_features:
144-
- security
145-
- alerting
146140
es_api_basic_auth_username: elastic
147141
es_api_basic_auth_password: elasticChanged
148142
es_api_sleep: 5

test/integration/xpack-upgrade.yml

-6
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
es_xpack_license: "{{ lookup('file', '/tmp/license.json') }}"
2424
es_plugins:
2525
- plugin: ingest-attachment
26-
es_xpack_features:
27-
- security
28-
- alerting
2926
es_api_basic_auth_username: elastic
3027
es_api_basic_auth_password: changeme
3128
es_api_sleep: 5
@@ -138,9 +135,6 @@
138135
es_xpack_license: "{{ lookup('file', '/tmp/license.json') }}"
139136
es_plugins:
140137
- plugin: ingest-attachment
141-
es_xpack_features:
142-
- security
143-
- alerting
144138
es_api_basic_auth_username: elastic
145139
es_api_basic_auth_password: elasticChanged
146140
es_api_sleep: 5

0 commit comments

Comments
 (0)