|
32 | 32 | elasticstack_ca_will_expire_soon: true
|
33 | 33 | when: >
|
34 | 34 | inventory_hostname == elasticstack_ca and
|
35 |
| - elasticsearch_cert_expiration_days is defined and |
36 |
| - elasticsearch_cert_expiration_days | int <= elasticsearch_cert_expiration_buffer | int |
| 35 | + elasticstack_ca_expiration_days is defined and |
| 36 | + elasticstack_ca_expiration_days | int <= elasticstack_ca_expiration_buffer | int |
37 | 37 |
|
38 | 38 | - name: Print the ca renew message
|
39 | 39 | debug:
|
40 | 40 | msg: |
|
41 |
| - Your ca will expire in {{ elasticstack_ca_expiration_days }}. |
| 41 | + Your ca will expire in {{ elasticstack_ca_expiration_days }} days. |
42 | 42 | Ansible will renew it and all elastic stack certificates
|
43 | 43 | when: >
|
44 | 44 | inventory_hostname == elasticstack_ca and
|
|
107 | 107 | path: "/etc/elasticsearch/certs/{{ ansible_hostname }}.p12"
|
108 | 108 | register: elasticsearch_cert_exists
|
109 | 109 |
|
110 |
| -- name: Get the elasticsearch certificate expiration date # noqa: risky-shell-pipe |
111 |
| - shell: >- |
112 |
| - if test -v BASH; then set -o pipefail; fi; |
113 |
| - openssl pkcs12 |
114 |
| - -in "/etc/elasticsearch/certs/{{ ansible_hostname }}.p12" |
115 |
| - -nodes |
116 |
| - -passin pass:"{{ elasticsearch_tls_key_passphrase }}" | |
117 |
| - openssl x509 -noout -enddate | |
118 |
| - awk -F'=' '{print $2}' |
119 |
| - register: elasticsearch_cert_expiration_date |
120 |
| - changed_when: false |
121 |
| - no_log: true |
| 110 | +- name: Get the elasticsearch certificate expiration date |
| 111 | + cert_info: |
| 112 | + path: "/etc/elasticsearch/certs/{{ ansible_hostname }}.p12" |
| 113 | + passphrase: "{{ elasticsearch_tls_key_passphrase | default(omit, true) }}" |
| 114 | + register: elasticsearch_cert_infos |
122 | 115 | when: elasticsearch_cert_exists.stat.exists | bool
|
123 | 116 |
|
124 | 117 | - name: Set the elasticsearch certificate expiration date in days
|
125 | 118 | set_fact:
|
126 |
| - elasticsearch_cert_expiration_days: "{{ ((elasticsearch_cert_expiration_date.stdout | to_datetime('%b %d %H:%M:%S %Y %Z')) - (ansible_date_time.date | to_datetime('%Y-%m-%d'))).days }}" |
127 |
| - when: elasticsearch_cert_expiration_date.skipped is not defined |
| 119 | + elasticsearch_cert_expiration_days: "{{ ((elasticsearch_cert_infos.not_valid_after | to_datetime()) - (ansible_date_time.date | to_datetime('%Y-%m-%d'))).days }}" |
| 120 | + when: elasticsearch_cert_infos.skipped is not defined |
128 | 121 |
|
129 | 122 | - name: Set elasticsearch certificate will expire soon to true
|
130 | 123 | set_fact:
|
|
134 | 127 | - name: Print the elasticsearch certificate renew message
|
135 | 128 | debug:
|
136 | 129 | msg: |
|
137 |
| - Your elasticsearch certificate will expire in {{ elasticsearch_cert_expiration_days }}. |
| 130 | + Your elasticsearch certificate will expire in {{ elasticsearch_cert_expiration_days }} days. |
138 | 131 | Ansible will renew it.
|
139 |
| - when: elasticsearch_cert_expiration_day is defined and elasticstack_ca_expiration_days | int <= elasticstack_ca_expiration_buffer | int |
| 132 | + when: elasticsearch_cert_expiration_days is defined and elasticsearch_cert_expiration_days | int <= elasticsearch_cert_expiration_buffer | int |
140 | 133 |
|
141 | 134 | - name: Backup elasticsearch certs on node then remove
|
142 | 135 | when: "'renew_es_cert' in ansible_run_tags or 'renew_ca' in ansible_run_tags or elasticsearch_cert_will_expire_soon | bool"
|
|
532 | 525 | - name: Wait for all instances to start
|
533 | 526 | include_tasks: wait_for_instance.yml
|
534 | 527 | loop: "{{ groups['elasticsearch'] }}"
|
| 528 | + tags: notest |
535 | 529 |
|
536 | 530 | - name: Force all notified handlers to run at this point, not waiting for normal sync points
|
537 | 531 | ansible.builtin.meta: flush_handlers
|
|
544 | 538 | include_tasks: wait_for_instance.yml
|
545 | 539 | loop: "{{ groups['elasticsearch'] }}"
|
546 | 540 | tags:
|
| 541 | + - notest |
547 | 542 | - certificates
|
548 | 543 | - renew_ca
|
549 | 544 | - renew_es_cert
|
|
0 commit comments