Skip to content

Commit 4b2e54c

Browse files
committed
rename elasticstack_ca to elasticstack_ca_host
1 parent 3d6673f commit 4b2e54c

File tree

10 files changed

+57
-56
lines changed

10 files changed

+57
-56
lines changed

docs/role-elasticsearch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The following variable was only integrated to speed up upgrades of non-productio
6060

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

63-
* *elasticstack_ca*: Set to the inventory hostname of the host that should house the CA for certificates for inter-node communication. (default: First node in the `elasticsearch` host group)
63+
* *elasticstack_ca_host*: Set to the inventory hostname of the host that should house the CA for certificates for inter-node communication. (default: First node in the `elasticsearch` host group)
6464
* *elasticstack_ca_name*: Distinguished name of the CA. (default: `CN=Elastic Certificate Tool Autogenerated CA`)
6565
* *elasticstack_ca_pass*: Password for Elasticsearch CA (default: `PleaseChangeMe`)
6666
* *elasticstack_ca_validity_period*: number of days that the generated CA are valid (default: 1095).

docs/role-kibana.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ These variables are identical over all our elastic related roles, hence the diff
3232
* *kibana_cert_will_expire_soon*: Set it to true to renew kibana certificate (default: `false`), Or run the playbook with `--tags renew_kibana_cert` to do that.
3333
* *elasticstack_kibana_host*: Hostname users use to connect to Kibana (default: FQDN of the host the role is executed on)
3434
* *elasticstack_kibana_port*: Port Kibana webinterface is listening on (default: `5601`)
35-
* *elasticstack_ca*: Set to the inventory hostname of the host that should house the CA for certificates for inter-node communication. (default: First node in the `elasticsearch` host group)
35+
* *elasticstack_ca_host*: Set to the inventory hostname of the host that should house the CA for certificates for inter-node communication. (default: First node in the `elasticsearch` host group)
3636
* *elasticstack_ca_dir*: Directory where on the Elasticsearch CA host certificates are stored. This is only useful in connection with out other Elastic Stack related roles. (default: `/opt/es-ca`)
3737
* *elasticstack_ca_pass*: Password for Elasticsearch CA (default: `PleaseChangeMe`)
3838
* *elasticstack_initial_passwords*: Path to file with initical elasticsearch passwords (default: `/usr/share/elasticsearch/initial_passwords`)

roles/elasticsearch/tasks/elasticsearch-security.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
ansible.builtin.stat:
55
path: "{{ elasticstack_ca_dir }}/elastic-stack-ca.p12"
66
register: elasticstack_ca_exists
7-
when: inventory_hostname == elasticstack_ca
7+
when: inventory_hostname == elasticstack_ca_host
88

99
- name: Get CA informations
1010
cert_info:
1111
path: "{{ elasticstack_ca_dir }}/elastic-stack-ca.p12"
1212
passphrase: "{{ elasticstack_ca_pass | default(omit, true) }}"
1313
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
1515

1616
- name: Set the ca expiration date in days
1717
ansible.builtin.set_fact:
1818
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
2020

2121
- name: Set ca will expire soon to true
2222
ansible.builtin.set_fact:
2323
elasticstack_ca_will_expire_soon: true
2424
when: >
25-
inventory_hostname == elasticstack_ca and
25+
inventory_hostname == elasticstack_ca_host and
2626
elasticstack_ca_expiration_days is defined and
2727
elasticstack_ca_expiration_days | int <= elasticstack_ca_expiration_buffer | int
2828
@@ -32,7 +32,7 @@
3232
Your ca will expire in {{ elasticstack_ca_expiration_days }} days.
3333
Ansible will renew it and all elastic stack certificates
3434
when: >
35-
inventory_hostname == elasticstack_ca and
35+
inventory_hostname == elasticstack_ca_host and
3636
elasticstack_ca_expiration_days is defined and
3737
elasticstack_ca_expiration_days | int <= elasticstack_ca_expiration_buffer | int
3838
@@ -48,7 +48,7 @@
4848
- groups[elasticstack_logstash_group_name] is defined
4949

5050
- 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)
5252
tags:
5353
- renew_ca
5454
block:
@@ -149,19 +149,19 @@
149149
state: absent
150150
when: elasticsearch_move_cert_directory.changed
151151

152-
- name: Backup elasticsearch certs on elasticstack_ca host then remove
152+
- name: Backup elasticsearch certs on elasticstack_ca_host host then remove
153153
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 }}"
155155
tags:
156156
- renew_ca
157157
- renew_es_cert
158158
block:
159-
- name: Check if cert file exists on elasticstack_ca host
159+
- name: Check if cert file exists on elasticstack_ca_host host
160160
ansible.builtin.stat:
161161
path: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12"
162162
register: elasticsearch_check_cert_file
163163

164-
- name: Move cert file on elasticstack_ca host
164+
- name: Move cert file on elasticstack_ca_host
165165
ansible.builtin.copy:
166166
src: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12"
167167
dest: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12_{{ ansible_date_time.iso8601_micro }}"
@@ -170,7 +170,7 @@
170170
when: elasticsearch_check_cert_file.stat.exists
171171
register: elasticsearch_move_cert_file
172172

173-
- name: Remove cert file on elasticstack_ca host
173+
- name: Remove cert file on elasticstack_ca_host
174174
ansible.builtin.file:
175175
path: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12"
176176
state: absent
@@ -217,14 +217,14 @@
217217
- name: Import Tasks elasticsearch-keystore.yml
218218
ansible.builtin.import_tasks: elasticsearch-keystore.yml
219219

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
222222
tags:
223223
- certificates
224224
- renew_ca
225225
- renew_es_cert
226226
block:
227-
- name: Configure ca on elasticstack_ca host
227+
- name: Configure ca on elasticstack_ca_host
228228
ansible.builtin.command: >
229229
/usr/share/elasticsearch/bin/elasticsearch-certutil ca
230230
--ca-dn {{ elasticstack_ca_name }}
@@ -236,7 +236,7 @@
236236
creates: "{{ elasticstack_ca_dir }}/elastic-stack-ca.p12"
237237
no_log: "{{ elasticstack_no_log }}"
238238

239-
- name: Create node certificates on elasticstack_ca host
239+
- name: Create node certificates on elasticstack_ca_host
240240
ansible.builtin.command: >
241241
/usr/share/elasticsearch/bin/elasticsearch-certutil cert
242242
--ca {{ elasticstack_ca_dir }}/elastic-stack-ca.p12
@@ -266,7 +266,7 @@
266266
src: "{{ elasticstack_ca_dir }}/ca.crt"
267267
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/ca.crt"
268268
flat: yes
269-
when: inventory_hostname == elasticstack_ca
269+
when: inventory_hostname == elasticstack_ca_host
270270
tags:
271271
- certificates
272272
- renew_ca
@@ -277,7 +277,7 @@
277277
src: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12"
278278
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}.p12"
279279
flat: yes
280-
delegate_to: "{{ elasticstack_ca }}"
280+
delegate_to: "{{ elasticstack_ca_host }}"
281281
tags:
282282
- certificates
283283
- renew_ca
@@ -361,7 +361,7 @@
361361
- name: Check for passwords being set
362362
ansible.builtin.stat:
363363
path: "{{ elasticstack_initial_passwords }}"
364-
delegate_to: "{{ elasticstack_ca }}"
364+
delegate_to: "{{ elasticstack_ca_host }}"
365365
register: elasticsearch_passwords_file
366366

367367
- name: Setting elasticsearch_http_protocol
@@ -412,7 +412,7 @@
412412
register: elasticstack_password
413413
changed_when: false
414414
no_log: "{{ elasticstack_no_log }}"
415-
delegate_to: "{{ elasticstack_ca }}"
415+
delegate_to: "{{ elasticstack_ca_host }}"
416416
when: elasticsearch_passwords_file.stat.exists | bool
417417

418418
- name: Check for API availability with elastic password
@@ -499,7 +499,7 @@
499499
if test -n "$(ps -p $$ | grep bash)"; then set -o pipefail; fi;
500500
/usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto -b >
501501
{{ elasticstack_initial_passwords }}
502-
when: inventory_hostname == elasticstack_ca
502+
when: inventory_hostname == elasticstack_ca_host
503503
no_log: "{{ elasticstack_no_log }}"
504504
args:
505505
creates: "{{ elasticstack_initial_passwords }}"
@@ -512,6 +512,6 @@
512512
owner: root
513513
group: root
514514
mode: 0600
515-
when: inventory_hostname == elasticstack_ca
515+
when: inventory_hostname == elasticstack_ca_host
516516

517517
# Maybe make sure that Elasticsearch is using the right protocol http(s) to connect, even in newly setup clusters

roles/elasticsearch/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@
314314

315315
- name: Show hint about passwords
316316
ansible.builtin.debug:
317-
msg: "Remember, your temporary passwords can be found on {{ elasticstack_ca }} in {{ elasticstack_initial_passwords }}"
317+
msg: "Remember, your temporary passwords can be found on {{ elasticstack_ca_host }} in {{ elasticstack_initial_passwords }}"
318318
when:
319319
- elasticsearch_security | bool
320320
- elasticstack_variant == "elastic"
321-
- inventory_hostname == elasticstack_ca
321+
- inventory_hostname == elasticstack_ca_host

roles/elasticstack/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ elasticstack_logstash_group_name: logstash
55
elasticstack_kibana_group_name: kibana
66

77
elasticstack_beats_port: 5044
8+
elasticstack_ca_host: "{{ groups[elasticstack_elasticsearch_group_name][0] }}"
89
elasticstack_ca_dir: /opt/es-ca
910
elasticstack_ca_expiration_buffer: 30
1011
elasticstack_ca_name: "CN=Elastic Certificate Tool Autogenerated CA"

roles/elasticstack/tasks/elasticstack-passwords.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- name: Check for passwords being set
44
ansible.builtin.stat:
55
path: "{{ elasticstack_initial_passwords }}"
6-
delegate_to: "{{ elasticstack_ca }}"
6+
delegate_to: "{{ elasticstack_ca_host }}"
77
register: elasticsearch_passwords_file
88

99
- name: Fetch Elastic password # noqa: risky-shell-pipe
@@ -14,5 +14,5 @@
1414
register: elasticstack_password
1515
changed_when: false
1616
no_log: "{{ elasticstack_no_log }}"
17-
delegate_to: "{{ elasticstack_ca }}"
17+
delegate_to: "{{ elasticstack_ca_host }}"
1818
when: elasticsearch_passwords_file.stat.exists | bool

roles/elasticstack/tasks/elasticstack-versions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- name: Set target version to Elasticsearch on CA host
88
ansible.builtin.set_fact:
99
elasticstack_version: "{{ ansible_facts.packages['elasticsearch'][0].version }}"
10-
delegate_to: "{{ elasticstack_ca }}"
10+
delegate_to: "{{ elasticstack_ca_host }}"
1111
when:
1212
- ansible_facts.packages['elasticsearch'][0].version is defined
1313
- elasticstack_version is undefined

roles/elasticstack/tasks/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
- '{{ ansible_os_family }}_{{ ansible_distribution_major_version }}.yml'
77
- '{{ ansible_os_family }}.yml'
88

9-
- name: Set elasticstack_ca variable if not already done by user
9+
- name: Set elasticstack_ca_host variable if not already done by user
1010
ansible.builtin.set_fact:
1111
elasticstack_ca: "{{ groups[elasticstack_elasticsearch_group_name][0] }}"
1212
when:
13-
- elasticstack_ca is undefined
13+
- elasticstack_ca_host is undefined
1414
- groups[elasticstack_elasticsearch_group_name][0] is defined
1515

16-
- name: Set elasticstack_ca variable if not already set to Elasticsearch server
16+
- name: Set elasticstack_ca_host variable if not already set to Elasticsearch server
1717
ansible.builtin.set_fact:
18-
elasticstack_ca: "{{ groups[elasticstack_logstash_group_name][0] }}"
18+
elasticstack_ca_host: "{{ groups[elasticstack_logstash_group_name][0] }}"
1919
when:
20-
- elasticstack_ca is undefined
20+
- elasticstack_ca_host is undefined
2121
- groups[elasticstack_logstash_group_name][0] is defined
2222

2323
- name: Set versions for components

roles/kibana/tasks/kibana-security.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
state: absent
5858
when: kibana_move_cert_directory.changed
5959

60-
- name: Backup kibana certs on elasticstack_ca host then remove
60+
- name: Backup kibana certs on elasticstack_ca_host then remove
6161
when: "'renew_kibana_cert' in ansible_run_tags or 'renew_ca' in ansible_run_tags or kibana_cert_will_expire_soon | bool"
62-
delegate_to: "{{ elasticstack_ca }}"
62+
delegate_to: "{{ elasticstack_ca_host }}"
6363
tags:
6464
- renew_ca
6565
- renew_kibana_cert
@@ -115,7 +115,7 @@
115115
when: kibana_move_cert_file.changed
116116

117117
- name: Block for key generation
118-
delegate_to: "{{ elasticstack_ca }}"
118+
delegate_to: "{{ elasticstack_ca_host }}"
119119
run_once: true
120120
tags:
121121
- certificates
@@ -174,7 +174,7 @@
174174
--dns {{ ansible_hostname }},{{ ansible_fqdn }},{{ inventory_hostname }}
175175
--pass {{ kibana_tls_key_passphrase }}
176176
--out {{ elasticstack_ca_dir }}/{{ ansible_hostname }}-kibana.p12
177-
delegate_to: "{{ elasticstack_ca }}"
177+
delegate_to: "{{ elasticstack_ca_host }}"
178178
no_log: "{{ elasticstack_no_log }}"
179179
args:
180180
creates: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}-kibana.p12"
@@ -188,7 +188,7 @@
188188
src: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}-kibana.p12"
189189
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-kibana.p12"
190190
flat: yes
191-
delegate_to: "{{ elasticstack_ca }}"
191+
delegate_to: "{{ elasticstack_ca_host }}"
192192
tags:
193193
- certificates
194194
- renew_ca
@@ -216,14 +216,14 @@
216216
register: kibana_password
217217
changed_when: false
218218
no_log: "{{ elasticstack_no_log }}"
219-
delegate_to: "{{ elasticstack_ca }}"
219+
delegate_to: "{{ elasticstack_ca_host }}"
220220

221221
- name: Fetch ca certificate from ca host to master
222222
ansible.builtin.fetch:
223223
src: "{{ elasticstack_ca_dir }}/ca.crt"
224224
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/ca.crt"
225225
flat: yes
226-
delegate_to: "{{ elasticstack_ca }}"
226+
delegate_to: "{{ elasticstack_ca_host }}"
227227
tags:
228228
- certificates
229229
- renew_ca

0 commit comments

Comments
 (0)