Skip to content

Commit 2da77e0

Browse files
ivareriwidhalmt
andauthored
Elasticsearch config (#288)
Minor tweaks and fixes to Elasticsearch configuration file --------- Co-authored-by: Thomas Widhalm <[email protected]>
1 parent f3ee73d commit 2da77e0

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

docs/role-elasticsearch.md

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ elasticsearch_extra_config:
4848
This variable activates a workaround to start on systems that have certain hardening measures active. See [Stackoverflow](https://stackoverflow.com/questions/47824643/unable-to-load-jna-native-support-library-elasticsearch-6-x/50371992#50371992) for details and logmessages to look for. **WARNING**: This will change your `/etc/sysconfig/elasticseach`or `/etc/default/elasticsearch` file and overwrite `ES_JAVA_OPTS`. See this [issue](https://github.com/netways/ansible-role-elasticsearch/issues/79) for details.
4949

5050
* *elasticsearch_jna_workaround*: Activate JNA workaround. (default: `false`)
51+
* *elasticsearch_ssl_verification_mode*: Defines how to verify the certificates presented by another party in the TLS connection
52+
* *elasticsearch_transport_port*: The port to bind for communication between nodes
53+
* *elasticsearch_seed_hosts*: Set elasticsearch seed hosts
54+
* *elasticsearch_security_enrollment*: Controls enrollment (of nodes and Kibana) to a local node that’s been autoconfigured for security.
5155

5256
These variables are identical over all our elastic related roles, hence the different naming schemes.
5357

roles/elasticsearch/defaults/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ elasticstack_ca_expiration_buffer: 30
4747
elasticsearch_cert_expiration_buffer: 30
4848
elasticstack_ca_will_expire_soon: false
4949
elasticsearch_cert_will_expire_soon: false
50+
elasticsearch_ssl_verification_mode: full
5051

5152
# only used internally
5253
elasticsearch_freshstart:

roles/elasticsearch/templates/elasticsearch.yml.j2

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{ ansible_managed | comment }}
2+
13
node.name: "{{ ansible_hostname }}"
24
path.data: {{ elasticsearch_datapath }}
35
path.logs: {{ elasticsearch_logpath }}
@@ -7,6 +9,12 @@ network.host: [ {{ elasticsearch_network_host }} ]
79
{% else %}
810
network.host: [ "_local_", "_site_" ]
911
{% endif %}
12+
{% if elasticstack_elasticsearch_http_port is defined %}
13+
http.port: "{{ elasticstack_elasticsearch_http_port }}"
14+
{% endif %}
15+
{% if elasticsearch_transport_port is defined %}
16+
transport.port: "{{ elasticsearch_transport_port }}"
17+
{% endif %}
1018
{% if elasticsearch_http_publish_host is defined %}
1119
http.publish_host: "{{ elasticsearch_http_publish_host }}"
1220
{% endif %}
@@ -22,11 +30,16 @@ node.roles: [ {% for type in elasticsearch_node_types %}{{ type }}{% if not loop
2230
discovery.type: single-node
2331
{% endif %}
2432

33+
{# Quickfix to override seed_hosts. Otherwise all nodes, not only master nodes are added to seed_hosts #}
34+
{% if elasticsearch_seed_hosts is defined %}
35+
discovery.seed_hosts: {{ elasticsearch_seed_hosts }}
36+
{% else %}
2537
{% if elasticstack_release | int < 8 or groups['elasticsearch'] | length > 1 %}
2638
discovery.seed_hosts: [ {% for host in groups['elasticsearch'] %}
2739
"{{ hostvars[host].ansible_default_ipv4.address | default(hostvars[host].ansible_all_ipv4_addresses[0]) }}"{% if not loop.last %},{% endif %}
2840
{% endfor %} ]
2941
{% endif %}
42+
{% endif %}
3043

3144
{% if not elaticsearch_cluster_set_up | bool and groups['elasticsearch'] | length > 1 %}
3245
{% if elasticsearch_node_types is defined %}
@@ -48,14 +61,18 @@ bootstrap.system_call_filter: false
4861
{% endif %}
4962
{% if elasticstack_variant == "elastic" %}
5063
xpack.ml.enabled: {{ elasticsearch_ml_enabled }}
64+
{% if elasticstack_release == 7 %}
5165
xpack.monitoring.collection.enabled: {{ elasticsearch_monitoring_enabled }}
66+
{% endif %}
5267
{% if elasticsearch_security | bool %}
5368
xpack.security.enabled: true
69+
{% if elasticsearch_security_enrollment is defined %}
70+
xpack.security.enrollment.enabled: {{ elasticsearch_security_enrollment }}
71+
{% endif %}
5472
xpack.security.transport.ssl.enabled: true
55-
#xpack.security.transport.ssl.verification_mode: certificate
56-
xpack.security.transport.ssl.verification_mode: none
57-
xpack.security.transport.ssl.keystore.path: certs/{{ ansible_hostname }}.p12
58-
xpack.security.transport.ssl.truststore.path: certs/{{ ansible_hostname }}.p12
73+
xpack.security.transport.ssl.verification_mode: {{ elasticsearch_ssl_verification_mode }}
74+
xpack.security.transport.ssl.keystore.path: certs/{{ ansible_hostname }}.p12
75+
xpack.security.transport.ssl.truststore.path: certs/{{ ansible_hostname }}.p12
5976
{% if elasticsearch_http_security | bool %}
6077
xpack.security.http.ssl.enabled: true
6178
xpack.security.http.ssl.keystore.path: certs/{{ ansible_hostname }}.p12

0 commit comments

Comments
 (0)