mirror of
https://github.com/luzifer-ansible/journalbeat.git
synced 2024-11-08 22:00:04 +00:00
74 lines
2 KiB
YAML
74 lines
2 KiB
YAML
---
|
|
|
|
- name: Check journalbeat version match
|
|
command: /usr/local/bin/journalbeat -version | grep -Fq '{{ journalbeat_version }}'
|
|
register: journalbeat_version_match
|
|
check_mode: no
|
|
ignore_errors: yes
|
|
changed_when: no
|
|
|
|
- name: Set download URL
|
|
set_fact:
|
|
journalbeat_download_url: 'https://github.com/mheese/journalbeat/releases/download/v{{ journalbeat_version }}/journalbeat-debian'
|
|
when: journalbeat_download_url is not defined
|
|
|
|
- name: Get requested journalbeat version
|
|
get_url:
|
|
url: '{{ journalbeat_download_url }}'
|
|
dest: /usr/local/bin/journalbeat
|
|
force: yes
|
|
mode: 0755
|
|
when: journalbeat_version_match.rc != 0
|
|
register: journalbeat_binary
|
|
|
|
- name: Install configuration
|
|
copy:
|
|
content: |
|
|
# Ansible managed
|
|
|
|
{{ journalbeat_config | to_nice_yaml }}
|
|
dest: /etc/journalbeat.yaml
|
|
owner: root
|
|
mode: 0600
|
|
register: journalbeat_configfile
|
|
|
|
- name: Create WorkingDirectory
|
|
file:
|
|
dest: /var/lib/journalbeat
|
|
state: directory
|
|
|
|
- name: Install systemd service
|
|
copy:
|
|
content: |
|
|
[Unit]
|
|
Description=JournalBeat log streaming service
|
|
After=network-online.target
|
|
Requires=network-online.target
|
|
|
|
[Service]
|
|
# Workaround: This file gets corrupted on unclean exit and then bricks the process
|
|
ExecStartPre=-/bin/rm /var/lib/journalbeat/.journalbeat-pending-queue
|
|
|
|
ExecStart=/usr/local/bin/journalbeat \
|
|
-c /etc/journalbeat.yaml \
|
|
-path.home /var/lib/journalbeat \
|
|
-path.logs /var/log
|
|
|
|
Restart=on-failure
|
|
RestartSec=5
|
|
WorkingDirectory=/var/lib/journalbeat
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
dest: /etc/systemd/system/journalbeat.service
|
|
register: journalbeat_service
|
|
|
|
- name: Restart and enable service
|
|
systemd:
|
|
name: journalbeat.service
|
|
daemon_reload: yes
|
|
state: restarted
|
|
enabled: yes
|
|
when: journalbeat_configfile.changed or journalbeat_service.changed or journalbeat_binary.changed
|
|
|
|
...
|