1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
- name: VictoriaLogs
tags: victoria-logs
hosts: lotus-land-story
vars:
version: "{{ versions.victoria_logs }}"
tasks:
- name: Make directories
ansible.builtin.file:
path: /mnt/lotus-land-story/{{ item }}
state: directory
mode: "0755"
loop:
- victoria-logs
- name: Get docker network
community.docker.docker_network:
name: lotus_land_story
register: docker_network
- name: Run VictoriaLogs
community.docker.docker_container:
restart: true
name: victoria-logs
image: docker.io/victoriametrics/victoria-logs:{{ version }}
command: -storageDataPath=/data -syslog.listenAddr.tcp=:514
restart_policy: unless-stopped
ports:
- "514:514" # syslog
# Exposed for journald via systemd-journal-upload - at some point, it
# might be nice to have journald go through vector, but would need to
# figure out how to make that work through docker.
- "9428:9428"
volumes:
- /mnt/lotus-land-story/victoria-logs:/data
networks:
- name: lotus_land_story
- name: Ship syslogs
ansible.builtin.copy:
content: |
*.* action(type="omfwd"
protocol="tcp"
target="127.0.0.1"
port="514"
Template="RSYSLOG_SyslogProtocol23Format"
TCP_Framing="octet-counted"
KeepAlive="on")
dest: /etc/rsyslog.d/50-promtail.conf
mode: "0644"
notify: Restart rsyslog
- name: Ship journald logs
block:
- name: Install systemd-journal-remote
ansible.builtin.apt:
name: systemd-journal-remote
state: present
- name: Set remote URL for uploading
ansible.builtin.lineinfile:
path: /etc/systemd/journal-upload.conf
regexp: '^URL='
insertafter: '^# URL='
line: URL=http://localhost:9428/insert/journald
- name: Run systemd-journal-remote
ansible.builtin.service:
name: systemd-journal-upload
state: started
handlers:
- name: Import restarts
ansible.builtin.import_tasks: restarts.yml
# vim: ft=yaml.ansible