faultline-remediation-agent
v0.1.0
Published
Faultline remediation agent — runs on a host Faultline has no inbound access to, polling for restart jobs and executing them locally
Readme
faultline-remediation-agent
Let Faultline runbooks restart a systemd service or Docker container on a host Faultline can't reach directly — your own VPS, an on-prem box, anything behind a firewall or NAT.
npm install -g faultline-remediation-agentWhy
Faultline's restart_ecs_service / scale_ecs_service runbook steps call
the AWS ECS API directly, which only works for AWS-hosted services. For
everything else — a systemd unit on a VPS, a Docker container on your own
box — Faultline has no way to reach in. It doesn't hold SSH keys to your
infrastructure and never opens a connection to it.
This agent closes that gap from the other direction: it runs on your host and polls out to Faultline for work.
runbook step fires → Faultline queues a job ← this agent polls, claims it,
runs it locally, reports backNo inbound port is ever opened on your host. If the agent process is down, nothing about it is reachable from the outside — the runbook step just times out after 5 minutes and fails, same as any other failed step.
Installation
npm install -g faultline-remediation-agentRequires Node.js 18 or later. systemctl and/or docker must be on PATH
for whichever action types you use.
Setup
Register the agent — Faultline dashboard → Settings → API Keys → New Agent. Name it (e.g. the hostname it'll run on) and copy the token shown once (
fla_...) — it isn't shown again.Configure it:
faultline-remediation-agent initPrompts for the token and the rest of the settings below, then writes
/etc/faultline-remediation-agent/agent.env(or a path you choose). If it can't write there (e.g. nosudo), it prints the file instead so you can save it yourself. Prefer to do it by hand? Copyagent.env.exampleto that path instead.Run it as a service — copy
faultline-remediation-agent.serviceto/etc/systemd/system/, then:systemctl enable --now faultline-remediation-agentOr run it directly for testing:
FAULTLINE_AGENT_TOKEN=fla_... faultline-remediation-agentUse it in a runbook — in a runbook's step editor, choose Restart Service (via Agent) or Restart Docker Container (via Agent), pick this agent from the dropdown, and name the unit or container.
Configuration
All configuration is environment variables (see
agent.env.example):
| Variable | Required | Default | Description |
|---|---|---|---|
| FAULTLINE_AGENT_TOKEN | Yes | — | This agent's token (fla_...), from Settings → API Keys → New Agent |
| FAULTLINE_API_URL | No | https://api.fltln.io | Faultline API origin to poll |
| POLL_INTERVAL_SECONDS | No | 5 | How often to poll when idle. Ignored while jobs are queued — it drains all of them back-to-back before waiting again |
| FAULTLINE_AGENT_ALLOWED_UNITS | No | (any) | Comma-separated systemd unit names this agent will restart. Unset = allow any name a runbook step specifies |
| FAULTLINE_AGENT_ALLOWED_CONTAINERS | No | (any) | Comma-separated container names this agent will restart. Unset = allow any |
The allowlists are a host-local second guard, independent of whatever the runbook step is configured to restart — useful if you want this specific host to only ever be able to touch specific things, regardless of what's authored on the Faultline side.
Security
- No inbound access. The agent only makes outbound HTTPS requests (long-poll for a job, POST the result). Nothing listens on this host.
- No stored SSH keys, no root requirement. Run it as an unprivileged
user with narrowly-scoped passwordless
sudofor exactly thesystemctl/docker restartcommands it needs — never as root. - No shell. Commands run via
execFile, never a shell, and the target name is defensively rejected if it starts with-(so it can never be parsed as a flag) — even though a runbook step's target name is already set by an admin on your Faultline tenant, not arbitrary user input. - Scoped token. An agent token (
fla_...) only unlocks this agent's polling endpoints — it cannot read incidents, services, or anything else in your Faultline account. - Revoke anytime. Settings → API Keys → Remediation Agents → revoke. Already-running jobs in flight will just time out and fail; nothing else changes.
How it works
The agent is a simple loop, not a long-held connection:
GET /remediation/jobs/nextwith its token — claims the oldest pending job for this agent, if any.- Runs it:
systemctl restart -- <unit>ordocker restart -- <container>. POST /remediation/jobs/:id/completewith the outcome.- If a job was handled, poll again immediately (there may be more queued);
otherwise wait
POLL_INTERVAL_SECONDSbefore polling again.
SIGTERM/SIGINT stop the loop after the current poll finishes — no job is
left half-reported.
Uninstalling
systemctl disable --now faultline-remediation-agent
npm uninstall -g faultline-remediation-agentThen revoke the agent in the Faultline dashboard so its token stops being valid.
License
MIT
