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_ppa: "ppa:adiscon/v8-stable"
rsyslog_debian_repo: "deb http://debian.adiscon.com/v8-stable wheezy/" rsyslog_debian_repo: "deb http://debian.adiscon.com/v8-stable wheezy/"
rsyslog_repo_key: "AEF0CF8E" rsyslog_repo_key: "AEF0CF8E"
rsyslog_pkg_status: "latest" rsyslog_pkg_status: "latest"
rsyslog_send_to_elasticsearch: True
rsyslog_use_inotify: True rsyslog_use_inotify: True
# Not used when inotify is enabled # Not used when inotify is enabled

View File

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