Logging at Fleet Scale: One Ansible Role to Ship journald to a Central Log Store
journald keeps logs locally, one host at a time. A shared Ansible role rolled a syslog forwarder out across the fleet in an afternoon - and shipped with the exact hardcoded-address bug it should have known better than to repeat.
Table of contents
journald is good at one thing: keeping a log on the box it ran on. The moment you have more than a couple of hosts, that stops being enough - a login failure, a crash loop, or a silent misconfiguration shows up as a gap you only notice if you happen to be looking at that specific machine at that specific moment. I'd had a central log store in the homelab for a while, standing in for an old, dead one-off container that an existing network device happened to point its syslog at. Everything else - every service host in the fleet - was still logging only to itself.
Why journald alone isn't enough
journald has a setting, ForwardToSyslog, that sounds like it should solve this by itself. It doesn't - it forwards to whatever's listening on the local syslog socket, and a minimal Debian host doesn't ship anything listening there by default. Flip the setting on a stock box and it forwards into a void. The actual fix is two steps, not one: install something that listens on that socket and knows how to ship logs onward, then let journald's existing forwarding do its job.
The role: install, configure, restart - only when something actually changed
Since this needed to land the same way on every host, it became a small shared Ansible role rather than a one-off change: install rsyslog, drop a forwarding rule, make sure the service is enabled, and restart it. The rule itself is short - read journald via rsyslog's imjournal input module, and ship everything out over TCP in RFC 5424 syslog format to the log store:
module(load="imjournal" StateFile="imjournal.state")
*.* action(type="omfwd"
target="<log store>"
port="514"
protocol="tcp"
Template="RSYSLOG_SyslogProtocol23Format"
action.resumeRetryCount="-1"
queue.type="linkedList"
queue.filename="vlogs_fwd")The one detail worth calling out: the restart task is gated on the config-deploy task's own register result, and only fires when: ...changed. Without that guard, every single Ansible run would bounce the logging daemon on every host, whether or not the forwarding rule actually changed - annoying on its own, and a bad habit to build into a role that's going to run unattended, repeatedly, forever.
One include_role line, repeated everywhere
The harder part wasn't the role itself, it was getting it onto every host. Each service in this homelab lives in its own repository, and each one's Ansible playbook started life as a literal copy of a shared template - not an include, a copy, taken at the moment the repo was created. There's no single file anywhere that every host's config inherits from, which means there's no single edit that reaches all of them either.
The fix for that is a level up: a separate, shared Ansible collection that every service repo already pulls in as a dependency, pinned not to a version number but to a branch. A new role added to that collection - and one include_role line added once to each consuming repo's playbook - is as close as this setup gets to a single change reaching everywhere. Push to that shared repo's main branch, and the next time any service's own pipeline runs, it picks the new role up automatically. No per-repo version bump required, no coordinated release - just the next normal run doing a little more than it did before.
What changed once every host could reach one place
Before this, finding anything meant knowing which host to even look at first, then SSHing in and grepping. After, a single query against the central log store sees every host's journal at once - which is a genuinely different way of debugging, not just a faster version of the old one. A problem that shows up as "something, somewhere, is unhappy" is now a query, not a guessing game about where to start looking.
The honest footnote: the fix shipped with the exact bug it was supposed to prevent
The new role's default forwarding target was a literal IP address, hardcoded into the role's defaults. That is precisely the failure mode this homelab has already been burned by more than once elsewhere: an address baked into automation as "just for now," which stays true right up until something gets rebalanced, re-provisioned, or moved - at which point every host silently stops shipping logs, with nothing anywhere complaining about it, because nothing's actual job depends on this role succeeding. A broken secrets fetch fails loudly. A broken log shipper just goes quiet.
Caught during review, fixed the same way every other instance of this pattern in this homelab eventually gets fixed: the literal address was pulled out and replaced with a stable internal hostname, resolved through the homelab's own DNS instead of pinned to whatever address happens to be true today. The lesson isn't new, and writing a role carefully doesn't make you immune to it - it's just as easy to write a new hardcoded address as it is to write a new hostname, and the convenient version is the one that compiles first.