Better support for different truststores
This commit is contained in:
parent
2b0343e135
commit
e01af7977f
1 changed files with 43 additions and 31 deletions
|
|
@ -1,20 +1,32 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
|
- name: set fact es_same_keystore
|
||||||
|
set_fact: es_same_keystore=false
|
||||||
|
|
||||||
|
- name: set fact es_same_keystore if stores match
|
||||||
|
set_fact: es_same_keystore=false
|
||||||
|
when: es_ssl_keystore == es_ssl_truststore
|
||||||
|
|
||||||
- name: ensure certificate directory exists
|
- name: ensure certificate directory exists
|
||||||
file:
|
file:
|
||||||
dest: "{{ es_ssl_certificate_path }}"
|
dest: "{{ es_ssl_certificate_path }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: Upload SSL/TLS keystore and truststore
|
- name: Upload SSL/TLS keystore
|
||||||
copy:
|
copy:
|
||||||
src: "{{ item }}"
|
src: "{{ es_ssl_keystore }}"
|
||||||
dest: "{{ es_ssl_certificate_path }}/{{ item | basename }}"
|
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_keystore | basename }}"
|
||||||
with_items:
|
|
||||||
- "{{ es_ssl_keystore }}"
|
|
||||||
- "{{ es_ssl_truststore }}"
|
|
||||||
when: es_ssl_keystore and es_ssl_truststore
|
when: es_ssl_keystore and es_ssl_truststore
|
||||||
#Restart if these change
|
|
||||||
notify: restart elasticsearch
|
notify: restart elasticsearch
|
||||||
register: copy_keystores
|
register: copy_keystore
|
||||||
|
|
||||||
|
- name: Upload SSL/TLS truststore
|
||||||
|
copy:
|
||||||
|
src: "{{ es_ssl_truststore }}"
|
||||||
|
dest: "{{ es_ssl_certificate_path }}/{{ es_ssl_truststore | basename }}"
|
||||||
|
when: es_ssl_keystore and es_ssl_truststore
|
||||||
|
notify: restart elasticsearch
|
||||||
|
register: copy_truststore
|
||||||
|
|
||||||
- name: Upload SSL/TLS key and certificate
|
- name: Upload SSL/TLS key and certificate
|
||||||
copy:
|
copy:
|
||||||
|
|
@ -36,23 +48,39 @@
|
||||||
notify: restart elasticsearch
|
notify: restart elasticsearch
|
||||||
when: es_ssl_certificate_authority | bool
|
when: es_ssl_certificate_authority | bool
|
||||||
|
|
||||||
- name: Set transport keystore password
|
- name: Set keystore password
|
||||||
shell: echo "{{ es_ssl_keystore_password }}" | {{ es_home }}/bin/elasticsearch-keystore add -x -f 'xpack.security.{{ item }}.ssl.keystore.secure_password'
|
shell: echo "{{ es_ssl_keystore_password }}" | {{ es_home }}/bin/elasticsearch-keystore add -x -f 'xpack.security.{{ item }}.ssl.keystore.secure_password'
|
||||||
no_log: True
|
no_log: True
|
||||||
when: es_ssl_keystore_password and copy_keystores.changed
|
when: es_ssl_keystore_password and copy_keystore.changed or (es_same_keystore and copy_truststore.changed)
|
||||||
with_items:
|
with_items:
|
||||||
- http
|
- http
|
||||||
- transport
|
- transport
|
||||||
|
|
||||||
- name: Set transport truststore password
|
- name: Set truststore password
|
||||||
shell: echo "{{ es_ssl_truststore_password }}" | {{ es_home }}/bin/elasticsearch-keystore add -x -f 'xpack.security.{{ item }}.ssl.truststore.secure_password'
|
shell: echo "{{ es_ssl_truststore_password }}" | {{ es_home }}/bin/elasticsearch-keystore add -x -f 'xpack.security.{{ item }}.ssl.truststore.secure_password'
|
||||||
no_log: True
|
no_log: True
|
||||||
when: es_ssl_truststore_password and copy_keystores.changed
|
when: es_ssl_truststore_password and copy_truststore.changed or (es_same_keystore and copy_keystore.changed)
|
||||||
with_items:
|
with_items:
|
||||||
- http
|
- http
|
||||||
- transport
|
- transport
|
||||||
|
|
||||||
- name: Set transport key password
|
- name: Remove keystore password
|
||||||
|
shell: "{{ es_home }}/bin/elasticsearch-keystore remove 'xpack.security.{{ item }}.ssl.keystore.secure_password'"
|
||||||
|
when: es_ssl_keystore_password == "" and copy_keystore.changed or (es_same_keystore and copy_truststore.changed)
|
||||||
|
ignore_errors: yes
|
||||||
|
with_items:
|
||||||
|
- http
|
||||||
|
- transport
|
||||||
|
|
||||||
|
- name: Remove truststore password
|
||||||
|
shell: "{{ es_home }}/bin/elasticsearch-keystore remove 'xpack.security.{{ item }}.ssl.truststore.secure_password'"
|
||||||
|
when: es_ssl_truststore_password == "" and copy_truststore.changed or (es_same_keystore and copy_keystore.changed)
|
||||||
|
ignore_errors: yes
|
||||||
|
with_items:
|
||||||
|
- http
|
||||||
|
- transport
|
||||||
|
|
||||||
|
- name: Set key password
|
||||||
shell: echo "{{ es_ssl_key_password }}" | {{ es_home }}/bin/elasticsearch-keystore add -x -f 'xpack.security.{{ item }}.ssl.secure_key_passphrase'
|
shell: echo "{{ es_ssl_key_password }}" | {{ es_home }}/bin/elasticsearch-keystore add -x -f 'xpack.security.{{ item }}.ssl.secure_key_passphrase'
|
||||||
no_log: True
|
no_log: True
|
||||||
when: es_ssl_key_password and copy_certificates.changed
|
when: es_ssl_key_password and copy_certificates.changed
|
||||||
|
|
@ -60,26 +88,10 @@
|
||||||
- http
|
- http
|
||||||
- transport
|
- transport
|
||||||
|
|
||||||
- name: Remove transport keystore password
|
- name: Remove key password
|
||||||
shell: "{{ es_home }}/bin/elasticsearch-keystore remove 'xpack.security.{{ item }}.ssl.keystore.secure_password'"
|
|
||||||
no_log: True
|
|
||||||
when: es_ssl_keystore_password == "" and copy_keystores.changed
|
|
||||||
with_items:
|
|
||||||
- http
|
|
||||||
- transport
|
|
||||||
|
|
||||||
- name: Remove transport truststore password
|
|
||||||
shell: "{{ es_home }}/bin/elasticsearch-keystore remove 'xpack.security.{{ item }}.ssl.truststore.secure_password'"
|
|
||||||
no_log: True
|
|
||||||
when: es_ssl_truststore_password == "" and copy_keystores.changed
|
|
||||||
with_items:
|
|
||||||
- http
|
|
||||||
- transport
|
|
||||||
|
|
||||||
- name: Remove transport key password
|
|
||||||
shell: "{{ es_home }}/bin/elasticsearch-keystore remove 'xpack.security.{{ item }}.ssl.secure_key_passphrase'"
|
shell: "{{ es_home }}/bin/elasticsearch-keystore remove 'xpack.security.{{ item }}.ssl.secure_key_passphrase'"
|
||||||
no_log: True
|
|
||||||
when: es_ssl_key_password == "" and copy_certificates.changed
|
when: es_ssl_key_password == "" and copy_certificates.changed
|
||||||
|
ignore_errors: yes
|
||||||
with_items:
|
with_items:
|
||||||
- http
|
- http
|
||||||
- transport
|
- transport
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue