Skip to content

Commit 2c90a8f

Browse files
authored
Failsafe for standalone usage (#113)
fixes #112 The roles of this community can either be used together relying on tasks and facts of each other or standalone. We need to make sure that no task that runs in standalone mode tries to access information from other roles.
1 parent 77858bf commit 2c90a8f

File tree

8 files changed

+14
-5
lines changed

8 files changed

+14
-5
lines changed

molecule/logstash_pipelines/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
logstash_pipeline_identifier_field_name: "[mytest][pipelines]"
3131
logstash_pipeline_identifier_defaults: true
3232
elastic_release: "{{ lookup('env', 'ELASTIC_RELEASE') | int}}"
33+
elastic_stack_full_stack: false
3334
tasks:
3435
- name: "Include Elastics repos role"
3536
include_role:

roles/beats/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
when:
1919
- beats_security | bool
2020
- elasticsearch_ca is undefined
21+
- groups['elasticsearch'] is defined
2122
tags:
2223
- certificates
2324
- renew_ca

roles/elasticsearch/handlers/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
- elastic_stack_full_stack: true
1414
- "not 'renew_ca' in ansible_run_tags"
1515
- "not elastic_ca_will_expire_soon | bool"
16+
- groups['kibana'] is defined

roles/elasticsearch/tasks/elasticsearch-security.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
state: stopped
5555
with_items: "{{ groups['logstash'] }}"
5656
delegate_to: "{{ item }}"
57-
when: "'renew_ca' in ansible_run_tags or elastic_ca_will_expire_soon | bool"
57+
when:
58+
- "'renew_ca' in ansible_run_tags or elastic_ca_will_expire_soon | bool"
59+
- groups['logstash'] is defined
5860

5961
- name: Backup ca directory on elasticsearch ca host then remove
6062
block:

roles/kibana/tasks/kibana-security.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
- name: Set elasticsearch_ca variable if not already done by user
1212
set_fact:
1313
elasticsearch_ca: "{{ groups['elasticsearch'][0] }}"
14-
when: elasticsearch_ca is undefined
14+
when:
15+
- elasticsearch_ca is undefined
16+
- groups['elasticsearch'] is defined
1517
tags:
1618
- certificates
1719
- renew_ca

roles/logstash/tasks/logstash-security.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
- name: Set elasticsearch_ca variable if not already done by user
1212
set_fact:
1313
elasticsearch_ca: "{{ groups['elasticsearch'][0] }}"
14-
when: elasticsearch_ca is undefined
14+
when:
15+
- elasticsearch_ca is undefined
16+
- groups['elasticsearch'] is defined
1517
tags:
1618
- certificates
1719
- configuration

roles/logstash/templates/elasticsearch-output.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ filter {
2020
{% endif %}
2121
output {
2222
elasticsearch {
23-
hosts => [ {% for host in logstash_elasticsearch %}"{{ hostvars[host].ansible_hostname }}:9200"{% if not loop.last %},{% endif %}{% endfor %}]
23+
hosts => [ {% for host in logstash_elasticsearch %}"{{ host }}:9200"{% if not loop.last %},{% endif %}{% endfor %}]
2424
validate_after_inactivity => {{ logstash_validate_after_inactivity }}
2525
{% if elastic_stack_full_stack | bool and logstash_security is defined and logstash_security | bool and elastic_variant == "elastic" %}
2626
keystore => "{{ logstash_certs_dir }}/keystore.pfx"

roles/logstash/templates/logstash.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pipeline.ecs_compatibility: {{ logstash_global_ecs }}
1515
{% endif %}
1616
{% if logstash_legacy_monitoring | bool and elastic_stack_full_stack | bool and elastic_variant == "elastic" and elastic_release | int < 8 %}
1717
xpack.monitoring.enabled: true
18-
xpack.monitoring.elasticsearch.hosts: [ {% for host in logstash_elasticsearch %}"https://{{ hostvars[host].ansible_hostname }}:9200"{% if not loop.last %},{% endif %}{% endfor %} ]
18+
xpack.monitoring.elasticsearch.hosts: [ {% for host in logstash_elasticsearch %}"https://{{ host }}:9200"{% if not loop.last %},{% endif %}{% endfor %} ]
1919
xpack.monitoring.elasticsearch.username: elastic
2020
xpack.monitoring.elasticsearch.password: {{ elastic_password_logstash.stdout }}
2121
xpack.monitoring.elasticsearch.ssl.certificate_authority: "{{ logstash_certs_dir }}/ca.crt"

0 commit comments

Comments
 (0)