|
4 | 4 | ansible.builtin.stat: |
5 | 5 | path: "{{ elasticstack_ca_dir }}/elastic-stack-ca.p12" |
6 | 6 | register: elasticstack_ca_exists |
7 | | - when: inventory_hostname == elasticstack_ca |
| 7 | + when: inventory_hostname == elasticstack_ca_host |
8 | 8 |
|
9 | 9 | - name: Get CA informations |
10 | 10 | cert_info: |
11 | 11 | path: "{{ elasticstack_ca_dir }}/elastic-stack-ca.p12" |
12 | 12 | passphrase: "{{ elasticstack_ca_pass | default(omit, true) }}" |
13 | 13 | register: elasticstack_ca_infos |
14 | | - when: inventory_hostname == elasticstack_ca and elasticstack_ca_exists.stat.exists | bool |
| 14 | + when: inventory_hostname == elasticstack_ca_host and elasticstack_ca_exists.stat.exists | bool |
15 | 15 |
|
16 | 16 | - name: Set the ca expiration date in days |
17 | 17 | ansible.builtin.set_fact: |
18 | 18 | elasticstack_ca_expiration_days: "{{ ((elasticstack_ca_infos.not_valid_after | to_datetime()) - (ansible_date_time.date | to_datetime('%Y-%m-%d'))).days }}" |
19 | | - when: inventory_hostname == elasticstack_ca and elasticstack_ca_infos.skipped is not defined |
| 19 | + when: inventory_hostname == elasticstack_ca_host and elasticstack_ca_infos.skipped is not defined |
20 | 20 |
|
21 | 21 | - name: Set ca will expire soon to true |
22 | 22 | ansible.builtin.set_fact: |
23 | 23 | elasticstack_ca_will_expire_soon: true |
24 | 24 | when: > |
25 | | - inventory_hostname == elasticstack_ca and |
| 25 | + inventory_hostname == elasticstack_ca_host and |
26 | 26 | elasticstack_ca_expiration_days is defined and |
27 | 27 | elasticstack_ca_expiration_days | int <= elasticstack_ca_expiration_buffer | int |
28 | 28 |
|
|
32 | 32 | Your ca will expire in {{ elasticstack_ca_expiration_days }} days. |
33 | 33 | Ansible will renew it and all elastic stack certificates |
34 | 34 | when: > |
35 | | - inventory_hostname == elasticstack_ca and |
| 35 | + inventory_hostname == elasticstack_ca_host and |
36 | 36 | elasticstack_ca_expiration_days is defined and |
37 | 37 | elasticstack_ca_expiration_days | int <= elasticstack_ca_expiration_buffer | int |
38 | 38 |
|
|
48 | 48 | - groups[elasticstack_logstash_group_name] is defined |
49 | 49 |
|
50 | 50 | - name: Backup ca directory on elasticsearch ca host then remove |
51 | | - when: (inventory_hostname == elasticstack_ca) and ('renew_ca' in "ansible_run_tags" or elasticstack_ca_will_expire_soon | bool) |
| 51 | + when: (inventory_hostname == elasticstack_ca_host) and ('renew_ca' in "ansible_run_tags" or elasticstack_ca_will_expire_soon | bool) |
52 | 52 | tags: |
53 | 53 | - renew_ca |
54 | 54 | block: |
|
149 | 149 | state: absent |
150 | 150 | when: elasticsearch_move_cert_directory.changed |
151 | 151 |
|
152 | | -- name: Backup elasticsearch certs on elasticstack_ca host then remove |
| 152 | +- name: Backup elasticsearch certs on elasticstack_ca_host host then remove |
153 | 153 | when: "'renew_es_cert' in ansible_run_tags or 'renew_ca' in ansible_run_tags or elasticsearch_cert_will_expire_soon | bool" |
154 | | - delegate_to: "{{ elasticstack_ca }}" |
| 154 | + delegate_to: "{{ elasticstack_ca_host }}" |
155 | 155 | tags: |
156 | 156 | - renew_ca |
157 | 157 | - renew_es_cert |
158 | 158 | block: |
159 | | - - name: Check if cert file exists on elasticstack_ca host |
| 159 | + - name: Check if cert file exists on elasticstack_ca_host host |
160 | 160 | ansible.builtin.stat: |
161 | 161 | path: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12" |
162 | 162 | register: elasticsearch_check_cert_file |
163 | 163 |
|
164 | | - - name: Move cert file on elasticstack_ca host |
| 164 | + - name: Move cert file on elasticstack_ca_host |
165 | 165 | ansible.builtin.copy: |
166 | 166 | src: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12" |
167 | 167 | dest: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12_{{ ansible_date_time.iso8601_micro }}" |
|
170 | 170 | when: elasticsearch_check_cert_file.stat.exists |
171 | 171 | register: elasticsearch_move_cert_file |
172 | 172 |
|
173 | | - - name: Remove cert file on elasticstack_ca host |
| 173 | + - name: Remove cert file on elasticstack_ca_host |
174 | 174 | ansible.builtin.file: |
175 | 175 | path: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12" |
176 | 176 | state: absent |
|
217 | 217 | - name: Import Tasks elasticsearch-keystore.yml |
218 | 218 | ansible.builtin.import_tasks: elasticsearch-keystore.yml |
219 | 219 |
|
220 | | -- name: Create ca and certificates on elasticstack_ca host |
221 | | - when: inventory_hostname == elasticstack_ca |
| 220 | +- name: Create ca and certificates on elasticstack_ca_host |
| 221 | + when: inventory_hostname == elasticstack_ca_host |
222 | 222 | tags: |
223 | 223 | - certificates |
224 | 224 | - renew_ca |
225 | 225 | - renew_es_cert |
226 | 226 | block: |
227 | | - - name: Configure ca on elasticstack_ca host |
| 227 | + - name: Configure ca on elasticstack_ca_host |
228 | 228 | ansible.builtin.command: > |
229 | 229 | /usr/share/elasticsearch/bin/elasticsearch-certutil ca |
230 | 230 | --ca-dn {{ elasticstack_ca_name }} |
|
236 | 236 | creates: "{{ elasticstack_ca_dir }}/elastic-stack-ca.p12" |
237 | 237 | no_log: "{{ elasticstack_no_log }}" |
238 | 238 |
|
239 | | - - name: Create node certificates on elasticstack_ca host |
| 239 | + - name: Create node certificates on elasticstack_ca_host |
240 | 240 | ansible.builtin.command: > |
241 | 241 | /usr/share/elasticsearch/bin/elasticsearch-certutil cert |
242 | 242 | --ca {{ elasticstack_ca_dir }}/elastic-stack-ca.p12 |
|
266 | 266 | src: "{{ elasticstack_ca_dir }}/ca.crt" |
267 | 267 | dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/ca.crt" |
268 | 268 | flat: yes |
269 | | - when: inventory_hostname == elasticstack_ca |
| 269 | + when: inventory_hostname == elasticstack_ca_host |
270 | 270 | tags: |
271 | 271 | - certificates |
272 | 272 | - renew_ca |
|
277 | 277 | src: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12" |
278 | 278 | dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}.p12" |
279 | 279 | flat: yes |
280 | | - delegate_to: "{{ elasticstack_ca }}" |
| 280 | + delegate_to: "{{ elasticstack_ca_host }}" |
281 | 281 | tags: |
282 | 282 | - certificates |
283 | 283 | - renew_ca |
|
361 | 361 | - name: Check for passwords being set |
362 | 362 | ansible.builtin.stat: |
363 | 363 | path: "{{ elasticstack_initial_passwords }}" |
364 | | - delegate_to: "{{ elasticstack_ca }}" |
| 364 | + delegate_to: "{{ elasticstack_ca_host }}" |
365 | 365 | register: elasticsearch_passwords_file |
366 | 366 |
|
367 | 367 | - name: Setting elasticsearch_http_protocol |
|
412 | 412 | register: elasticstack_password |
413 | 413 | changed_when: false |
414 | 414 | no_log: "{{ elasticstack_no_log }}" |
415 | | - delegate_to: "{{ elasticstack_ca }}" |
| 415 | + delegate_to: "{{ elasticstack_ca_host }}" |
416 | 416 | when: elasticsearch_passwords_file.stat.exists | bool |
417 | 417 |
|
418 | 418 | - name: Check for API availability with elastic password |
|
499 | 499 | if test -n "$(ps -p $$ | grep bash)"; then set -o pipefail; fi; |
500 | 500 | /usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto -b > |
501 | 501 | {{ elasticstack_initial_passwords }} |
502 | | - when: inventory_hostname == elasticstack_ca |
| 502 | + when: inventory_hostname == elasticstack_ca_host |
503 | 503 | no_log: "{{ elasticstack_no_log }}" |
504 | 504 | args: |
505 | 505 | creates: "{{ elasticstack_initial_passwords }}" |
|
512 | 512 | owner: root |
513 | 513 | group: root |
514 | 514 | mode: 0600 |
515 | | - when: inventory_hostname == elasticstack_ca |
| 515 | + when: inventory_hostname == elasticstack_ca_host |
516 | 516 |
|
517 | 517 | # Maybe make sure that Elasticsearch is using the right protocol http(s) to connect, even in newly setup clusters |
0 commit comments