2019-06-27 13:53:23 -07:00
|
|
|
---
|
2019-10-16 16:36:43 +01:00
|
|
|
|
|
|
|
|
- name: set fact es_same_keystore
|
|
|
|
|
set_fact: es_same_keystore=false
|
|
|
|
|
|
|
|
|
|
- name: set fact es_same_keystore if stores match
|
2019-10-16 16:39:31 +01:00
|
|
|
set_fact: es_same_keystore=true
|
2019-10-16 16:36:43 +01:00
|
|
|
when: es_ssl_keystore == es_ssl_truststore
|
|
|
|
|
|
2020-10-12 10:02:25 +02:00
|
|
|
- name: Ensure certificate directory exists
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-06-27 13:53:23 -07:00
|
|
|
file:
|
|
|
|
|
dest: "{{ es_ssl_certificate_path }}"
|
|
|
|
|
state: directory
|
2019-10-31 10:55:40 +00:00
|
|
|
owner: root
|
|
|
|
|
group: "{{ es_group }}"
|
2019-11-28 07:02:33 +01:00
|
|
|
mode: "750"
|
2020-10-12 10:02:25 +02:00
|
|
|
when: es_ssl_upload
|
2019-06-27 13:53:23 -07:00
|
|
|
|
2019-10-16 16:36:43 +01:00
|
|
|
- name: Upload SSL/TLS keystore
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-06-27 13:53:23 -07:00
|
|
|
copy:
|
2019-10-16 16:36:43 +01:00
|
|
|
src: "{{ es_ssl_keystore }}"
|
|
|
|
|
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_keystore | basename }}"
|
2019-10-31 10:55:40 +00:00
|
|
|
owner: "{{ es_user }}"
|
|
|
|
|
group: "{{ es_group }}"
|
2019-11-28 07:02:33 +01:00
|
|
|
mode: "640"
|
2020-10-12 10:02:25 +02:00
|
|
|
when: es_ssl_upload and es_ssl_keystore and es_ssl_truststore
|
2019-10-16 16:36:43 +01:00
|
|
|
notify: restart elasticsearch
|
|
|
|
|
register: copy_keystore
|
|
|
|
|
|
|
|
|
|
- name: Upload SSL/TLS truststore
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-10-16 16:36:43 +01:00
|
|
|
copy:
|
|
|
|
|
src: "{{ es_ssl_truststore }}"
|
|
|
|
|
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_truststore | basename }}"
|
2019-10-31 10:55:40 +00:00
|
|
|
owner: "{{ es_user }}"
|
|
|
|
|
group: "{{ es_group }}"
|
2019-11-28 07:02:33 +01:00
|
|
|
mode: "640"
|
2020-10-12 10:02:25 +02:00
|
|
|
when: es_ssl_upload and es_ssl_keystore and es_ssl_truststore
|
2019-10-11 16:33:09 +01:00
|
|
|
notify: restart elasticsearch
|
2019-10-16 16:36:43 +01:00
|
|
|
register: copy_truststore
|
2019-06-27 13:53:23 -07:00
|
|
|
|
2019-10-11 16:09:05 +01:00
|
|
|
- name: Upload SSL/TLS key and certificate
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-10-11 16:09:05 +01:00
|
|
|
copy:
|
|
|
|
|
src: "{{ item }}"
|
|
|
|
|
dest: "{{ es_ssl_certificate_path }}/{{ item | basename }}"
|
2019-10-31 10:55:40 +00:00
|
|
|
owner: "{{ es_user }}"
|
|
|
|
|
group: "{{ es_group }}"
|
2019-11-28 07:02:33 +01:00
|
|
|
mode: "640"
|
2019-10-11 16:09:05 +01:00
|
|
|
with_items:
|
|
|
|
|
- "{{ es_ssl_key }}"
|
|
|
|
|
- "{{ es_ssl_certificate }}"
|
2020-10-12 10:02:25 +02:00
|
|
|
when: es_ssl_upload and es_ssl_key and es_ssl_certificate
|
2019-10-11 16:33:09 +01:00
|
|
|
#Restart if these change
|
|
|
|
|
notify: restart elasticsearch
|
2019-10-11 16:09:05 +01:00
|
|
|
register: copy_certificates
|
2019-06-27 13:53:23 -07:00
|
|
|
|
|
|
|
|
- name: Upload SSL Certificate Authority
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-06-27 13:53:23 -07:00
|
|
|
copy:
|
|
|
|
|
src: "{{ es_ssl_certificate_authority }}"
|
|
|
|
|
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_certificate_authority | basename }}"
|
2019-10-31 10:55:40 +00:00
|
|
|
owner: "{{ es_user }}"
|
|
|
|
|
group: "{{ es_group }}"
|
2019-11-28 07:02:33 +01:00
|
|
|
mode: "640"
|
2019-10-12 00:03:47 +01:00
|
|
|
#Restart if this changes
|
|
|
|
|
notify: restart elasticsearch
|
2020-10-12 10:02:25 +02:00
|
|
|
when: es_ssl_upload and (es_ssl_certificate_authority is defined) and (es_ssl_certificate_authority|length > 0)
|
2019-10-12 00:57:49 +01:00
|
|
|
|
2019-10-16 16:36:43 +01:00
|
|
|
- name: Set keystore password
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-10-13 16:18:55 +01:00
|
|
|
shell: echo "{{ es_ssl_keystore_password }}" | {{ es_home }}/bin/elasticsearch-keystore add -x -f 'xpack.security.{{ item }}.ssl.keystore.secure_password'
|
2019-10-12 00:57:49 +01:00
|
|
|
no_log: True
|
2019-10-18 17:51:44 +01:00
|
|
|
when: es_ssl_keystore_password and (copy_keystore.changed or (es_same_keystore and copy_truststore.changed))
|
2019-10-12 00:57:49 +01:00
|
|
|
with_items:
|
|
|
|
|
- http
|
|
|
|
|
- transport
|
|
|
|
|
|
2019-10-16 16:36:43 +01:00
|
|
|
- name: Set truststore password
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-10-13 16:18:55 +01:00
|
|
|
shell: echo "{{ es_ssl_truststore_password }}" | {{ es_home }}/bin/elasticsearch-keystore add -x -f 'xpack.security.{{ item }}.ssl.truststore.secure_password'
|
2019-10-12 00:57:49 +01:00
|
|
|
no_log: True
|
2019-10-18 17:51:44 +01:00
|
|
|
when: es_ssl_truststore_password and (copy_truststore.changed or (es_same_keystore and copy_keystore.changed))
|
2019-10-12 00:57:49 +01:00
|
|
|
with_items:
|
|
|
|
|
- http
|
|
|
|
|
- transport
|
|
|
|
|
|
2019-10-16 16:36:43 +01:00
|
|
|
- name: Remove keystore password
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-10-16 16:36:43 +01:00
|
|
|
shell: "{{ es_home }}/bin/elasticsearch-keystore remove 'xpack.security.{{ item }}.ssl.keystore.secure_password'"
|
2019-10-18 17:51:44 +01:00
|
|
|
when: es_ssl_keystore_password == "" and (copy_keystore.changed or (es_same_keystore and copy_truststore.changed))
|
2019-10-16 16:36:43 +01:00
|
|
|
ignore_errors: yes
|
2019-10-12 00:57:49 +01:00
|
|
|
with_items:
|
|
|
|
|
- http
|
|
|
|
|
- transport
|
|
|
|
|
|
2019-10-16 16:36:43 +01:00
|
|
|
- name: Remove truststore password
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-10-16 16:36:43 +01:00
|
|
|
shell: "{{ es_home }}/bin/elasticsearch-keystore remove 'xpack.security.{{ item }}.ssl.truststore.secure_password'"
|
2019-10-18 17:51:44 +01:00
|
|
|
when: es_ssl_truststore_password == "" and (copy_truststore.changed or (es_same_keystore and copy_keystore.changed))
|
2019-10-16 16:36:43 +01:00
|
|
|
ignore_errors: yes
|
2019-10-12 00:57:49 +01:00
|
|
|
with_items:
|
|
|
|
|
- http
|
|
|
|
|
- transport
|
|
|
|
|
|
2019-10-16 16:36:43 +01:00
|
|
|
- name: Set key password
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-10-16 16:36:43 +01:00
|
|
|
shell: echo "{{ es_ssl_key_password }}" | {{ es_home }}/bin/elasticsearch-keystore add -x -f 'xpack.security.{{ item }}.ssl.secure_key_passphrase'
|
2019-10-12 00:57:49 +01:00
|
|
|
no_log: True
|
2019-10-16 16:36:43 +01:00
|
|
|
when: es_ssl_key_password and copy_certificates.changed
|
2019-10-12 00:57:49 +01:00
|
|
|
with_items:
|
|
|
|
|
- http
|
|
|
|
|
- transport
|
|
|
|
|
|
2019-10-16 16:36:43 +01:00
|
|
|
- name: Remove key password
|
2020-01-28 14:23:22 -08:00
|
|
|
become: yes
|
2019-10-13 16:18:55 +01:00
|
|
|
shell: "{{ es_home }}/bin/elasticsearch-keystore remove 'xpack.security.{{ item }}.ssl.secure_key_passphrase'"
|
2019-10-12 00:57:49 +01:00
|
|
|
when: es_ssl_key_password == "" and copy_certificates.changed
|
2019-10-16 16:36:43 +01:00
|
|
|
ignore_errors: yes
|
2019-10-12 00:57:49 +01:00
|
|
|
with_items:
|
|
|
|
|
- http
|
|
|
|
|
- transport
|