From 6a7f8ebe6de3b98af60ac5c2e246ab5832720b32 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 17 Nov 2016 16:17:35 +0100 Subject: [PATCH] Filebeat role --- filebeat/README.md | 12 +++++++++ filebeat/defaults/main.yml | 2 ++ filebeat/tasks/main.yml | 52 ++++++++++++++++++++++++++++++++++++++ vagrant.yml | 6 ++--- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 filebeat/README.md create mode 100644 filebeat/defaults/main.yml create mode 100644 filebeat/tasks/main.yml diff --git a/filebeat/README.md b/filebeat/README.md new file mode 100644 index 00000000..84b9adc6 --- /dev/null +++ b/filebeat/README.md @@ -0,0 +1,12 @@ +# filebeat + +Install Filebeat. + +## Tasks + +Everything is in the `tasks/main.yml` file. + +## Available variables + +* `filebeat_kibana_dashboards`: import dashboards in Kibana (defaults to false). +* `filebeat_logstash_plugin`: install Logstash plugin (defaults to false); diff --git a/filebeat/defaults/main.yml b/filebeat/defaults/main.yml new file mode 100644 index 00000000..e5d78014 --- /dev/null +++ b/filebeat/defaults/main.yml @@ -0,0 +1,2 @@ +filebeat_kibana_dashboards: False +filebeat_logstash_plugin: False diff --git a/filebeat/tasks/main.yml b/filebeat/tasks/main.yml new file mode 100644 index 00000000..4073c1f0 --- /dev/null +++ b/filebeat/tasks/main.yml @@ -0,0 +1,52 @@ +--- + +- name: APT https transport is enabled + apt: + name: apt-transport-https + state: installed + tags: + - system + - packages + +- name: Elastic GPG key is installed + apt_key: + url: https://artifacts.elastic.co/GPG-KEY-elasticsearch + state: present + tags: + - system + - packages + +- name: Elastic sources list is available + apt_repository: + repo: "deb https://artifacts.elastic.co/packages/5.x/apt stable main" + state: present + tags: + - system + - packages + +- name: Filebeat is installed + apt: + name: filebeat + update_cache: yes + state: installed + tags: + - packages + +- name: Filebeat service is enabled + service: + name: filebeat + enabled: yes + +- name: Kibana dashboards are imported + command: /usr/share/filebeat/scripts/import_dashboards + failed_when: '"fail" in stdout' + when: filebeat_kibana_dashboards + +- name: is logstash-plugin available? + stat: + path: /usr/share/logstash/bin/logstash-plugin + register: logstash_plugin + +- name: Logstash plugin is installed + command: /usr/share/logstash/bin/logstash-plugin install logstash-input-beats + when: filebeat_logstash_plugin and logstash_plugin.stat.exists diff --git a/vagrant.yml b/vagrant.yml index c8c4fdb7..5d975f3c 100644 --- a/vagrant.yml +++ b/vagrant.yml @@ -5,8 +5,8 @@ roles: # - { role: apt-upgrade, apt_upgrade_mode: safe } - - apt-upgrade - - apt-backports + # - apt-upgrade + # - apt-backports # - munin # - monit # - redis @@ -24,4 +24,4 @@ # - { role: elasticsearch, elasticsearch_custom_tmpdir: "/var/lib/elasticsearch/tmp" } # - elasticsearch # - elasticsearch-plugin-head - - kibana + - filebeat