Skip to content

Commit

Permalink
Add missing opendistro_elasticsearch host in filebeat config
Browse files Browse the repository at this point in the history
  • Loading branch information
rafzei committed Jul 23, 2020
1 parent 1fd38b9 commit 2512e20
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 45 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-0.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- [#1398](https://github.com/epiphany-platform/epiphany/issues/1398) - Vault installation fails when using canal/calico network plugin
- [#1412](https://github.com/epiphany-platform/epiphany/issues/1412) - Certificate in Vault is also generated or copied even if flag in configuration tls_disable is set to true
- [#1408](https://github.com/epiphany-platform/epiphany/issues/1408) - Epiphany does not support upgrades for Kubernetes in HA mode
- [#1482](https://github.com/epiphany-platform/epiphany/issues/1482) - Epicli upgrade: flannel CNI plugin is not upgraded to v0.12.0
- [#1347](https://github.com/epiphany-platform/epiphany/issues/1347) - [BUG] Kibana config always points its elasticsearch.hosts to a "logging" VM

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
src: filebeat.yml.j2
register: modify_filebeat_yml

- name: Enable auditd module
shell: >-
filebeat modules enable auditd
register: enable_module
changed_when: "'Enabled auditd' in enable_module.stdout"

- name: Set Filebeat to be started after Docker
block:
- name: Create directory (filebeat.service.d)
Expand All @@ -37,6 +31,17 @@

- name: Start/restart and enable filebeat service
block:
- name: Enable auditd module
command: filebeat modules enable auditd
register: enable_module
changed_when: "'Enabled auditd' in enable_module.stdout"

- name: Enable and start filebeat service
systemd:
name: filebeat
state: started
enabled: true

- name: Restart filebeat service
systemd:
name: filebeat
Expand All @@ -45,22 +50,20 @@
or modify_filebeat_unit_dependencies.changed
or enable_module.changed

- name: Enable and start filebeat service
systemd:
name: filebeat
state: started
enabled: true

- name: Verify Filebeat is running
- name: Verify filebeat is running
command: systemctl is-active filebeat
changed_when: false
when:
- groups['logging'][0] is defined
retries: 10
delay: 1
register: result
until: result is succeeded
when: groups['logging'][0] is defined
or groups['opendistro_for_elasticsearch'][0] is defined

- name: Stop and disable filebeat service
systemd:
name: filebeat
state: stopped
enabled: false
when:
- groups['logging'][0] is undefined
when: groups['logging'][0] is undefined
and groups['opendistro_for_elasticsearch'][0] is undefined
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,15 @@
- name: Include installation tasks
include_tasks: install-filebeat.yml

- name: Set facts for filebeat.yml template
block:

- name: Set flag if logging output exists
set_fact:
logging_output_exists: False

- name: Set flag if logging output exists
set_fact:
logging_output_exists: True
when:
- groups["logging"] is defined
- groups["logging"] | length > 0

- name: Set value for setup.kibana.host
set_fact:
setup_kibana_host: >-
{{ hostvars[groups['kibana'][0]].ansible_default_ipv4.address + ':5601' }}
when:
- groups['kibana'][0] is defined
- name: Set value for setup.kibana.host
set_fact:
setup_kibana_host: >-
{{ hostvars[groups['kibana'][0]].ansible_default_ipv4.address + ':5601' }}
when:
- groups['kibana'][0] is defined

- name: Include auditd configuration tasks
include_tasks: configure-auditd.yml

- name: Include filebeat configuration tasks
include_tasks: configure-filebeat.yml
include_tasks: configure-filebeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,22 @@ setup.template.settings:
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
{% if logging_output_exists %}
hosts:
{% for host in groups['logging'] %}
- "https://{{hostvars[host]['ansible_hostname']}}:9200"
{% endfor %}
{% if groups['logging'] is defined or groups['opendistro_for_elasticsearch'] is defined %}
hosts:
{% if groups['logging'] is defined %}
# Logging hosts:
{% for host in groups['logging'] -%}
- "https://{{hostvars[host]['ansible_hostname']}}:9200"
{% endfor %}
{% endif %}

{% if groups['opendistro_for_elasticsearch'] is defined %}
# Opendistro hosts:
{% for host in groups['opendistro_for_elasticsearch'] -%}
- "https://{{hostvars[host]['ansible_hostname']}}:9200"
{% endfor %}
{% endif %}

protocol: "https"
ssl.verification_mode: none
username: logstash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
server.host: "{{ ansible_default_ipv4.address | default(ansible_all_ipv4_addresses[0]) }}"
elasticsearch.hosts:
{% if groups['logging'] is defined %}
{%- for host in groups['logging'] %}
# Logging hosts:
{% for host in groups['logging'] %}
- "https://{{hostvars[host]['ansible_hostname']}}:9200"
{% endfor %}
{% endif %}

{% if groups['opendistro_for_elasticsearch'] is defined %}
{%- for host in groups['opendistro_for_elasticsearch'] -%}
# Opendistro hosts :
{% for host in groups['opendistro_for_elasticsearch'] %}
- "https://{{hostvars[host]['ansible_hostname']}}:9200"
{% endfor %}
{% endif %}
Expand Down

0 comments on commit 2512e20

Please sign in to comment.