metricbeat: new variables to configure elasticsearch hosts and auth

This commit is contained in:
Jérémy Lecour 2018-08-30 13:47:48 +02:00 committed by Jérémy Lecour
parent cb9e48b41d
commit cfd5e3d7f2
3 changed files with 30 additions and 0 deletions

View File

@ -11,6 +11,7 @@ The **patch** part changes incrementally at each release.
## [Unreleased]
### Added
* metricbeat: new variables to configure elasticsearch hosts and auth
### Changed

View File

@ -1,2 +1,7 @@
---
elastic_stack_version: "6.x"
metricbeat_elasticsearch_hosts:
- "localhost:9200"
metricbeat_elasticsearch_auth_username: ""
metricbeat_elasticsearch_auth_password: ""

View File

@ -39,3 +39,27 @@
systemd:
name: metricbeat
enabled: yes
- name: Metricbeat knows where to find Elasticsearch
lineinfile:
dest: /etc/metricbeat/metricbeat.yml
regexp: '^ hosts: .*'
line: " hosts: [\"{{ metricbeat_elasticsearch_hosts | join('\", \"') }}\"]"
insertafter: "output.elasticsearch:"
notify: restart metricbeat
when:
- metricbeat_elasticsearch_hosts
- name: Metricbeat auth/username for Elasticsearch are configured
lineinfile:
dest: /etc/metricbeat/metricbeat.yml
regexp: '{{ item.regexp }}'
line: '{{ item.line }}'
insertafter: "output.elasticsearch:"
with_items:
- { regexp: '^ #username: .*', line: ' username: "{{ metricbeat_elasticsearch_auth_username }}"' }
- { regexp: '^ #password: .*', line: ' password: "{{ metricbeat_elasticsearch_auth_password }}"' }
notify: restart metricbeat
when:
- metricbeat_elasticsearch_auth_username != ""
- metricbeat_elasticsearch_auth_password != ""