You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.9 KiB
64 lines
1.9 KiB
---
|
|
|
|
- include_tasks: install_filebeat_{{ ansible_os_family }}.yml
|
|
- include_tasks: install_journalbeat_{{ ansible_os_family }}.yml
|
|
when: ansible_service_mgr == 'systemd'
|
|
tags: logs
|
|
|
|
# Not useful, and prevent fast completion for journalctl
|
|
- name: Remove journalbeat shortcut
|
|
file: path={{ item }} state=absent
|
|
loop:
|
|
- /bin/journalbeat
|
|
- /usr/bin/journalbeat
|
|
when: ansible_service_mgr == 'systemd'
|
|
tags: logs
|
|
|
|
- name: Create ansible module directories
|
|
file: path=/etc/filebeat/ansible_{{ item }}.d state=directory
|
|
loop:
|
|
- modules
|
|
- inputs
|
|
tags: logs
|
|
|
|
- name: Deploy filebeat configuration
|
|
template: src={{ item }}.j2 dest=/etc/filebeat/{{ item }}
|
|
loop:
|
|
- filebeat.yml
|
|
- ansible_modules.d/system.yml
|
|
- ansible_modules.d/auditd.yml
|
|
- ansible_inputs.d/system_specific.yml
|
|
notify: restart filebeat
|
|
tags: logs
|
|
|
|
- name: Deploy journalbeat configuration
|
|
template: src=journalbeat.yml.j2 dest=/etc/journalbeat/journalbeat.yml
|
|
notify: restart journalbeat
|
|
tags: logs
|
|
|
|
- name: Override filebeat unit
|
|
template: src=filebeat.service.j2 dest=/etc/systemd/system/filebeat.service
|
|
register: filebeat_unit
|
|
tags: logs
|
|
|
|
- name: Override journalbeat unit
|
|
template: src=journalbeat.service.j2 dest=/etc/systemd/system/journalbeat.service
|
|
register: filebeat_journalbeat_unit
|
|
when: ansible_service_mgr == 'systemd'
|
|
tags: logs
|
|
|
|
- name: Reload systemd
|
|
systemd: daemon_reload=True
|
|
when: filebeat_unit.changed or (filebeat_journalbeat_unit is defined and filebeat_journalbeat_unit.changed)
|
|
tags: logs
|
|
|
|
- name: Start and enable filebeat
|
|
service: name=filebeat state=started enabled=True
|
|
tags: logs
|
|
|
|
- name: Handle journalbeat service
|
|
service:
|
|
name: journalbeat
|
|
state: "{{ (ansible_service_mgr == 'systemd') | ternary('started','stopped') }}"
|
|
enabled: "{{ (ansible_service_mgr == 'systemd') | ternary(True,False) }} "
|
|
tags: logs
|
|
|