--- - hosts: promclients gather_facts: true become: true tasks: - name: Ensure rsyslog is installed ansible.builtin.package: name: rsyslog state: latest - name: Ensure rsyslog is enabled ansible.builtin.systemd_service: name: rsyslog enabled: true state: started - name: Remove any forwarding file if exists ansible.builtin.file: path: /etc/rsyslog.d/forward.conf state: absent - name: Get control node headnet IP address ansible.builtin.shell: tailscale status | head -1 | awk '{print $1}' register: ctrl_headnet_ip_addr delegate_to: 127.0.0.1 - name: Configure log forwarding ansible.builtin.blockinfile: path: /etc/rsyslog.d/forward.conf create: true owner: root group: root mode: 0644 block: | # Forward to desktop.headscale.moonshadow.dev ({{ctrl_headnet_ip_addr.stdout}}) *.* action(type="omfwd" target="{{ctrl_headnet_ip_addr.stdout}}" port="514" protocol="tcp" action.resumeRetryCount="100" queue.type="linkedList" queue.size="10000") - name: Restart rsyslog ansible.builtin.systemd_service: name: rsyslog enabled: true state: restarted