ansible-role-logstash/tasks/main.yml

73 lines
1.5 KiB
YAML
Raw Normal View History

2019-09-10 06:57:26 +00:00
---
- name: install dependencies packages
package:
name: '{{ packages }}'
vars:
packages:
- default-jre
- apt-transport-https
retries: 2
register: result
until: result is succeeded
tags: logstash
- name: add repository key
apt_key:
url: https://artifacts.elastic.co/GPG-KEY-elasticsearch
retries: 2
register: result
until: result is succeeded
tags: logstash
- name: add repository
apt_repository:
repo: 'deb https://artifacts.elastic.co/packages/{{ logstash_major_version }}.x/apt stable main'
tags: logstash
- name: install package
apt:
name: logstash
retries: 2
register: result
until: result is succeeded
tags: logstash
- name: copy general config file
copy:
content: '{{ logstash_full_config|to_yaml }}'
dest: /etc/logstash/logstash.yml
owner: root
group: root
mode: 0644
notify: restart logstash
tags: logstash
- name: copy input, output and filter files
template:
src: '{{ item }}.conf.j2'
dest: '/etc/logstash/conf.d/{{ item }}.conf'
owner: root
group: root
mode: 0644
validate: /usr/share/logstash/bin/logstash -t -f %s
2019-09-10 06:57:26 +00:00
loop:
- input
- output
- filter
notify: restart logstash
tags: logstash
- name: install plugins
logstash_plugin:
name: '{{ item.name }}'
state: '{{ item.state|default("present") }}'
loop: '{{ logstash_plugins }}'
tags: logstash
- name: enable and start service
systemd:
name: logstash
state: started
enabled: true
tags: logstash