2016-11-17 16:17:35 +01:00
|
|
|
---
|
|
|
|
|
2017-07-13 14:43:07 +02:00
|
|
|
- name: APT https transport is enabled
|
|
|
|
apt:
|
|
|
|
name: apt-transport-https
|
|
|
|
state: present
|
|
|
|
tags:
|
|
|
|
- filebeat
|
|
|
|
- packages
|
|
|
|
|
|
|
|
- name: Elastic GPG key is installed
|
|
|
|
apt_key:
|
|
|
|
# url: https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
|
|
|
data: "{{ lookup('file', 'elasticsearch.key') }}"
|
|
|
|
state: present
|
|
|
|
tags:
|
|
|
|
- filebeat
|
|
|
|
- packages
|
|
|
|
|
|
|
|
- name: Elastic sources list is available
|
|
|
|
apt_repository:
|
2017-11-26 12:32:12 +01:00
|
|
|
repo: "deb https://artifacts.elastic.co/packages/{{ elastic_stack_version | mandatory }}/apt stable main"
|
2017-11-14 10:26:48 +01:00
|
|
|
filename: elastic
|
2017-07-13 14:43:07 +02:00
|
|
|
state: present
|
|
|
|
update_cache: yes
|
|
|
|
tags:
|
|
|
|
- filebeat
|
|
|
|
- packages
|
2017-05-21 11:13:48 +02:00
|
|
|
|
2016-11-17 16:17:35 +01:00
|
|
|
- name: Filebeat is installed
|
|
|
|
apt:
|
|
|
|
name: filebeat
|
2017-01-12 17:37:48 +01:00
|
|
|
state: present
|
2016-11-17 16:17:35 +01:00
|
|
|
tags:
|
2017-07-13 14:43:07 +02:00
|
|
|
- filebeat
|
|
|
|
- packages
|
2016-11-17 16:17:35 +01:00
|
|
|
|
|
|
|
- name: Filebeat service is enabled
|
2017-10-08 22:31:22 +02:00
|
|
|
systemd:
|
2016-11-17 16:17:35 +01:00
|
|
|
name: filebeat
|
|
|
|
enabled: yes
|
|
|
|
|
|
|
|
- name: is logstash-plugin available?
|
|
|
|
stat:
|
|
|
|
path: /usr/share/logstash/bin/logstash-plugin
|
2017-03-24 14:15:09 +01:00
|
|
|
check_mode: no
|
2016-11-17 16:17:35 +01:00
|
|
|
register: logstash_plugin
|
|
|
|
|
2016-11-22 16:43:45 +01:00
|
|
|
- name: is logstash-input-beats installed?
|
2017-05-19 22:31:17 +02:00
|
|
|
command: grep logstash-input-beats /usr/share/logstash/Gemfile
|
2017-03-24 14:15:09 +01:00
|
|
|
check_mode: no
|
2016-11-22 16:43:45 +01:00
|
|
|
register: logstash_plugin_installed
|
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
2016-11-17 16:17:35 +01:00
|
|
|
when: filebeat_logstash_plugin and logstash_plugin.stat.exists
|
2016-11-22 16:43:45 +01:00
|
|
|
|
|
|
|
- block:
|
2017-11-07 12:18:02 +01:00
|
|
|
- include_role:
|
|
|
|
name: remount-usr
|
2016-11-22 16:43:45 +01:00
|
|
|
|
|
|
|
- name: Logstash plugin is installed
|
|
|
|
command: /usr/share/logstash/bin/logstash-plugin install logstash-input-beats
|
2017-05-19 22:52:33 +02:00
|
|
|
when:
|
|
|
|
- filebeat_logstash_plugin
|
|
|
|
- logstash_plugin.stat.exists
|
|
|
|
- not logstash_plugin_installed | success
|
2019-01-29 16:57:45 +01:00
|
|
|
|
|
|
|
- name: cloud_metadata processor is disabled
|
|
|
|
replace:
|
|
|
|
dest: /etc/filebeat/filebeat.yml
|
|
|
|
regexp: '^(\s+)(- add_cloud_metadata:)'
|
|
|
|
replace: '\1# \2'
|
|
|
|
notify: restart filebeat
|
|
|
|
when: not filebeat_processors_cloud_metadata
|
|
|
|
|
|
|
|
- name: cloud_metadata processor is disabled
|
|
|
|
lineinfile:
|
|
|
|
dest: /etc/filebeat/filebeat.yml
|
|
|
|
line: " - add_cloud_metadata: ~"
|
|
|
|
insert_after: '^processors:'
|
|
|
|
notify: restart filebeat
|
|
|
|
when: filebeat_processors_cloud_metadata
|