openstack-ansible-ops/graylog/graylog-forward-logs.yml
Jean-Philippe Evrard afca2222b2 Add Graylog Central Logging
This adds a central logging using graylog2 with little to no
code.

Change-Id: I63e59e249329ececf0598552b95329b38b4ed32c
2018-04-24 21:43:03 +00:00

45 lines
1.6 KiB
YAML

---
- hosts: all:!log_hosts
gather_facts: no
vars:
graylog_forwarder_system_packages:
- python-systemd
graylog_forwarder_pip_packages:
- gelfclient==0.0.7
- journal2gelf==2.0.0
tasks:
#- name: Gather variables for each operating system
# include_vars: "{{ item }}"
# with_first_found:
# - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
# - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
# - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
# - "{{ ansible_distribution | lower }}.yml"
# - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml"
# - "{{ ansible_os_family | lower }}.yml"
# tags:
# - always
- name: Install graylog forwarder package requirements
package:
name: "{{ graylog_forwarder_system_packages }}"
state: present
# Graylog wasn't build in repo, and requires running "isolated"
- name: Install graylog forwarder requirements
pip:
name: "{{ graylog_forwarder_pip_packages }}"
state: present
- name: Install the log forwarder service.
include_role:
name: systemd_service
with_items: "{{ graylog_targets }}"
loop_control:
loop_var: graylog_target
vars:
systemd_services:
- service_name: gelf-forwarder
state: started
execstarts:
- "/usr/local/bin/journal2gelf {{ graylog_target }}"