library/roles/logstash-rsyslog: Fix tags, add tasks that remove the logstash configuration if disabled.

This commit is contained in:
Andrea Dell'Amico 2016-11-07 14:11:50 +01:00
parent 55cdf9feb1
commit ddb60cf945
2 changed files with 36 additions and 44 deletions

View File

@ -1,10 +1,11 @@
---
#
rsyslog_install_newer_package: True
rsyslog_repo_install: True
rsyslog_ppa: "ppa:adiscon/v8-stable"
rsyslog_debian_repo: "deb http://debian.adiscon.com/v8-stable wheezy/"
rsyslog_repo_key: "AEF0CF8E"
rsyslog_pkg_status: "latest"
rsyslog_send_to_elasticsearch: True
rsyslog_use_inotify: True
# Not used when inotify is enabled

View File

@ -1,70 +1,61 @@
---
- name: Install the rsyslog ppa on ubuntu precise or later
apt_repository: repo='{{ rsyslog_ppa }}'
apt_repository: repo='{{ rsyslog_ppa }}' update_cache=yes
when:
- is_ubuntu
- rsyslog_install_newer_package
register: rsyslog_ubuntu_repo
tags:
- rsyslog
- logstash
- rsyslog_repo_install
tags: [ 'rsyslog', 'logstash' ]
- name: Remove the rsyslog ppa on ubuntu precise or later
apt_repository: repo='{{ rsyslog_ppa }}' update_cache=yes state=absent
when:
- is_ubuntu
- not rsyslog_repo_install
tags: [ 'rsyslog', 'logstash' ]
- name: Install the rsyslog repo key on debian wheezy
apt_key: keyserver=keys.gnupg.net id=AEF0CF8E state=present
when:
- is_debian7
- rsyslog_install_newer_package
tags:
- rsyslog
- logstash
- rsyslog_repo_install
tags: [ 'rsyslog', 'logstash' ]
- name: Install the rsyslog repository on debian wheezy
copy: content="{{ rsyslog_debian_repo }}\n" dest=/etc/apt/sources.list.d/adiscon-rsyslog.list
register: rsyslog_debian_repo
apt_repository: repo="{{ rsyslog_debian_repo }}" state=present update_cache=yes
when:
- is_debian7
- rsyslog_install_newer_package
tags:
- rsyslog
- logstash
- rsyslog_repo_install
tags: [ 'rsyslog', 'logstash' ]
- name: Update apt cache
apt: update_cache=yes
when: (rsyslog_ubuntu_repo|changed) or (rsyslog_debian_repo|changed)
tags:
- rsyslog
- logstash
- name: Remove the rsyslog repository on debian wheezy
apt_repository: repo="{{ rsyslog_debian_repo }}" state=absent update_cache=yes
when:
- is_debian7
- not rsyslog_repo_install
tags: [ 'rsyslog', 'logstash' ]
- name: Add the syslog user to the adm group so it can read all the log files
user: name=syslog groups=adm
tags:
- rsyslog
- logstash
tags: [ 'rsyslog', 'logstash' ]
- name: Upgrade rsyslog and install the elasticsearch module
apt: pkg={{ item }} state={{ rsyslog_pkg_status }}
apt: pkg={{ item }} state={{ rsyslog_pkg_status }} update_cache=yes cache_valid_time=1800
with_items:
- rsyslog
- rsyslog-elasticsearch
tags:
- rsyslog
- logstash
tags: [ 'rsyslog', 'logstash' ]
- name: Add a rsyslog configuration to send logfiles data to a logstash collector or directly to elasticsearch
template: src=rsyslog-logstash.conf.j2 dest=/etc/rsyslog.d/90-rsyslog-logstash.conf owner=root group=root mode=0444
when: rsyslog_install_newer_package
notify:
Restart rsyslog
tags:
- logstash
- rsyslog
when:
- rsyslog_repo_install
- rsyslog_send_to_elasticsearch
notify: Restart rsyslog
tags: [ 'rsyslog', 'logstash' ]
- name: Add a rsyslog configuration to send logfiles data to a logstash collector when using the original and old rsyslog package
template: src=old-rsyslog-logstash.conf.j2 dest=/etc/rsyslog.d/90-rsyslog-logstash.conf owner=root group=root mode=0444
when: not rsyslog_install_newer_package
notify:
Restart rsyslog
tags:
- logstash
- rsyslog
- name: Remove the rsyslog configuration to send logfiles data to a logstash collector or directly to elasticsearch
file: dest=/etc/rsyslog.d/90-rsyslog-logstash.conf state=absent
when: not rsyslog_send_to_elasticsearch
notify: Restart rsyslog
tags: [ 'rsyslog', 'logstash' ]