Playbooks I use for my homelab
1---
2- hosts: promclients
3 gather_facts: true
4 become: true
5
6 tasks:
7 - name: Ensure rsyslog is installed
8 ansible.builtin.package:
9 name: rsyslog
10 state: latest
11
12 - name: Ensure rsyslog is enabled
13 ansible.builtin.systemd_service:
14 name: rsyslog
15 enabled: true
16 state: started
17
18 - name: Remove any forwarding file if exists
19 ansible.builtin.file:
20 path: /etc/rsyslog.d/forward.conf
21 state: absent
22
23 - name: Get control node headnet IP address
24 ansible.builtin.shell: tailscale status | head -1 | awk '{print $1}'
25 register: ctrl_headnet_ip_addr
26 delegate_to: 127.0.0.1
27
28 - name: Configure log forwarding
29 ansible.builtin.blockinfile:
30 path: /etc/rsyslog.d/forward.conf
31 create: true
32 owner: root
33 group: root
34 mode: 0644
35 block: |
36 # Forward to desktop.headscale.moonshadow.dev ({{ctrl_headnet_ip_addr.stdout}})
37 *.* action(type="omfwd" target="{{ctrl_headnet_ip_addr.stdout}}" port="514" protocol="tcp"
38 action.resumeRetryCount="100"
39 queue.type="linkedList" queue.size="10000")
40
41 - name: Restart rsyslog
42 ansible.builtin.systemd_service:
43 name: rsyslog
44 enabled: true
45 state: restarted