Home/Templates/Send host logs off the machine
Send host logs off the machine
Forward system logs to a collector so they outlive the machine that wrote them.
Ansible
Why bother
Logs that only exist on the host disappear when the host does, which is exactly what someone arranges when they want the story to go away. Sending them somewhere else as they are written means you still have them afterwards. It also means one search covers the whole fleet.
Make something happen on a host, such as a login or a new process. Find it on the collector within a minute or two.
How it works
Set it up
Pick your platform, then open the level you want. Each level is complete on its own. Read the comments in the files as you go. Anything with a real consequence is explained on the line where it happens.
Ansible. rsyslog forwarding, with a queue that survives the collector being down
What you need first
- A collector reachable from the hosts that accepts syslog over TCP.
- For the Standard version, the CA that signed the collector certificate present on every host. The role checks and stops if it is missing.
What it creates
- /etc/rsyslog.d/10-forward.conf with a disk-backed queue
- A spool directory for messages waiting to be sent
- A raised RateLimitBurst in journald.conf
The code
Quick startReady
collector_host: logs.example.internalplaybook.yml, line 23collector_port: 514playbook.yml, line 24
ansible all -i inventory.ini -m ping
Proves Ansible can reach every machine before anything changes.ansible-playbook -i inventory.ini playbook.yml --check --diff
Shows each change it would make, line by line. Changes nothing.ansible-playbook -i inventory.ini playbook.yml
Makes the change.ansible-playbook -i inventory.ini playbook.yml
Run it once more. The recap should end with changed=0.
No inventory yet? A one-machine inventory.ini:
[all] web-01 ansible_host=10.0.0.11 ansible_user=ubuntu
Syntax passedAnsible lint passed
Last run 2026-10-02.
Open playbook.yml as plain text
StandardReady
ansible all -i inventory.ini -m ping
Proves Ansible can reach every machine before anything changes.ansible-playbook -i inventory.ini site.yml --check --diff
Shows each change it would make, line by line. Changes nothing.ansible-playbook -i inventory.ini site.yml
Makes the change.ansible-playbook -i inventory.ini site.yml
Run it once more. The recap should end with changed=0.
No inventory yet? A one-machine inventory.ini:
[all] web-01 ansible_host=10.0.0.11 ansible_user=ubuntu
Syntax passedAnsible lint passed
Last run 2026-10-02.
Open main.yml as plain text
Open main.yml as plain text
Open main.yml as plain text
Open forward.conf.j2 as plain text
Open site.yml as plain text
HardenedReady
ansible all -i inventory.ini -m ping
Proves Ansible can reach every machine before anything changes.ansible-playbook -i inventory.ini site.yml --check --diff
Shows each change it would make, line by line. Changes nothing.ansible-playbook -i inventory.ini site.yml
Makes the change.ansible-playbook -i inventory.ini site.yml
Run it once more. The recap should end with changed=0.
No inventory yet? A one-machine inventory.ini:
[all] web-01 ansible_host=10.0.0.11 ansible_user=ubuntu
Syntax passedAnsible lint passed
Last run 2026-10-02.
Open guard.yml as plain text
Open settings.yml as plain text
Open site.yml as plain text
How to check it worked
Write a test line with logger -t iac-test hello. Find it on the collector within a few seconds.
journald throws messages away above its own rate limit before rsyslog ever sees them. Raising the rsyslog limit alone changes nothing, which is why a burst during an incident still goes missing. The Standard role raises both.
How to undo it
Remove the file and restart rsyslog. Anything already queued on disk is either delivered or dropped, depending on how long the collector has been away.
What it costs
None on the host beyond the disk the queue uses. The charge, if there is one, is on the receiving side per gigabyte.
Ansible. Sysmon, and Windows Event Forwarding to a collector
What you need first
- An Active Directory domain containing the sources and the collector. Kerberos is what lets sources authenticate and encrypt without certificates.
- One Windows Server to be the collector, and an inventory with groups called collector and sources. Ansible reaches all of them over WinRM.
- The ansible.windows collection at the version in requirements.yml.
- The SHA-256 of a Sysmon.zip you downloaded and checked. The templates stop without it, and refuse a download that does not match.
- Sources able to reach the collector on TCP 5985.
What it creates
- Sysmon64 with a configuration that names every event type, so nothing depends on Sysmon's defaults
- A source-initiated subscription on the collector, open to domain computers and domain controllers
- Security, System, and Sysmon collected in full (Quick start)
- Security and Sysmon in full, plus chosen PowerShell, service, log-cleared, and Defender events (Standard)
- Read access for the forwarder to the Security and Sysmon logs
- The collector address in each source's forwarding policy
- Advanced audit policy, command lines in event 4688, PowerShell script block logging, and larger Security, Sysmon, and ForwardedEvents logs (Standard)
The code
Quick startReady
collector_fqdn: wec01.example.internalplaybook.yml, line 32sysmon_sha256: ""playbook.yml, line 33
ansible-galaxy collection install ansible.windows:==3.3.0
Installs the Windows modules, at the version the checks ran against.ansible all -i inventory.ini -m ansible.windows.win_ping
Proves Ansible can reach every machine before anything changes.ansible-playbook -i inventory.ini playbook.yml --check --diff
Shows each change it would make, line by line. Changes nothing.ansible-playbook -i inventory.ini playbook.yml
Makes the change.ansible-playbook -i inventory.ini playbook.yml
Run it once more. The recap should end with changed=0.
No inventory yet? An inventory.ini for machines in an Active Directory domain. Kerberos needs pywinrm with its Kerberos extra on the machine running Ansible.
[collector] wec01.corp.example.com [sources] app-01.corp.example.com [windows:children] collector sources [windows:vars] ansible_connection=winrm ansible_winrm_transport=kerberos ansible_port=5985
Syntax failedAnsible lint failed
Last run 2026-10-02.
Open playbook.yml as plain text
StandardReady
ansible-galaxy collection install -r requirements.yml
Installs the Windows modules, at the version the checks ran against.ansible all -i inventory.ini -m ansible.windows.win_ping
Proves Ansible can reach every machine before anything changes.ansible-playbook -i inventory.ini site.yml --check --diff
Shows each change it would make, line by line. Changes nothing.ansible-playbook -i inventory.ini site.yml
Makes the change.ansible-playbook -i inventory.ini site.yml
Run it once more. The recap should end with changed=0.
No inventory yet? An inventory.ini for machines in an Active Directory domain. Kerberos needs pywinrm with its Kerberos extra on the machine running Ansible.
[collector] wec01.corp.example.com [sources] app-01.corp.example.com [windows:children] collector sources [windows:vars] ansible_connection=winrm ansible_winrm_transport=kerberos ansible_port=5985
Syntax failedAnsible lint failed
Last run 2026-10-02.
Open requirements.yml as plain text
Open main.yml as plain text
Open main.yml as plain text
Open main.yml as plain text
Open sysmonconfig.xml.j2 as plain text
Open main.yml as plain text
Open main.yml as plain text
Open main.yml as plain text
Open subscription.xml.j2 as plain text
Open main.yml as plain text
Open main.yml as plain text
Open main.yml as plain text
Open main.yml as plain text
Open main.yml as plain text
Open main.yml as plain text
Open main.yml as plain text
Open site.yml as plain text
HardenedReady
ansible-galaxy collection install ansible.windows:==3.3.0
Installs the Windows modules, at the version the checks ran against.ansible all -i inventory.ini -m ansible.windows.win_ping
Proves Ansible can reach every machine before anything changes.ansible-playbook -i inventory.ini site.yml --check --diff
Shows each change it would make, line by line. Changes nothing.ansible-playbook -i inventory.ini site.yml
Makes the change.ansible-playbook -i inventory.ini site.yml
Run it once more. The recap should end with changed=0.
No inventory yet? An inventory.ini for machines in an Active Directory domain. Kerberos needs pywinrm with its Kerberos extra on the machine running Ansible.
[collector] wec01.corp.example.com [sources] app-01.corp.example.com [windows:children] collector sources [windows:vars] ansible_connection=winrm ansible_winrm_transport=kerberos ansible_port=5985
Syntax failedAnsible lint passed
Last run 2026-10-02.
Open guard.yml as plain text
Open settings.yml as plain text
Open site.yml as plain text
How to check it worked
On the collector, wecutil gr iac-baseline lists each source as Active. Start any program on a source, then on the collector run Get-WinEvent -LogName ForwardedEvents -MaxEvents 20 and find the Sysmon event for it.
The forwarder runs as NETWORK SERVICE, which cannot read the Security or Sysmon logs by default. The subscription then shows the source as active while those two logs never arrive, which looks like a quiet machine. Both templates grant read access on each log.
On Windows Server 2016 and 2019 the collector service can run in its own process, and is then refused the WinRM address, so no event arrives from anywhere. The templates apply Microsoft's published URL permission fix on the collector.
Domain controllers are not members of Domain Computers, so a subscription open only to Domain Computers never hears from them, and they are usually the sources that matter most. Both templates allow Domain Controllers too.
A domain Group Policy object that sets audit policy replaces local settings at its next refresh. The Standard role reads the policy back with auditpol and fails if process creation is not being recorded, which is how you find out a GPO owns it.
How to undo it
On sources, delete the SubscriptionManager value under HKLM\SOFTWARE\Policies\Microsoft\Windows\EventLog\EventForwarding and run Sysmon64.exe -u to remove Sysmon. On the collector, wecutil ds iac-baseline removes the subscription. Events already forwarded stay in ForwardedEvents until it wraps.
What it costs
Nothing to license. Disk on each source for the larger logs, and on the collector for ForwardedEvents. Security events from a domain controller are the largest share of the volume.