Set up / Policy file
Policy file
The model proposes one action. The policy decides whether it runs, waits for approval, or is blocked. It lives in ~/.nightwatch/policy.yaml and is re-read on every decision, so edits apply immediately.
Three lanes
AUTO
Runs on its ownThe action runs right away and is logged. Nobody is paged.
ASK
Waits for a human codeThe action is held. The on-call phone gets a one-time code; it runs only after the code is entered.
NEVER
Blocked and escalatedThe action is refused and the on-call person is paged instead.
escalate and ignore are always allowed, because they never change the host.
Build a policy
Set a lane for each tool and the YAML updates. Copy it into ~/.nightwatch/policy.yaml.
ActionsAUTO 3ASK 1NEVER 0
restart_serviceRestart an allowed user-space servicefree_diskClear an allowed spool, temp or cache mountretry_uploadRetry a stalled or failed upload bundlequarantine_uploadMove a suspicious upload into quarantineSMS to on-callCodes for ASK, pages for NEVER
Voice call if unacknowledged
Protected services always blocked, even if listed under auto
sshdsystemdsystemd-journaldkernelfirewalldauditd
Protected mounts never cleaned
//boot/etc/usr
# Nightwatch policy · bay-04
version: 1
auto:
restart_service: [upload-agent, tls-tunnel, av-scanner, sync-worker]
free_disk: [/var/spool/, /tmp, /var/tmp, /mnt/offload-cache]
retry_upload: true
ask:
quarantine_upload: true
never:
services: [sshd, systemd, systemd-journald, kernel, firewalld, auditd]
mounts: [/, /boot, /etc, /usr]
escalation:
sms: on-call-primary
voice: after 5m unacknowledged
approval:
local_fallback: true
Full example
version: 1
auto:
restart_service: [upload-agent, tls-tunnel, av-scanner, sync-worker]
free_disk: [/var/spool/, /tmp, /var/tmp, /mnt/offload-cache]
retry_upload: true
ask:
quarantine_upload: true
never:
services: [sshd, systemd, systemd-journald, kernel, firewalld, auditd]
mounts: [/, /boot, /etc, /usr]
escalation:
sms: on-call-primary
voice: after 5m unacknowledged
quiet_hours: 22:00-07:00
approval:
local_fallback: trueFields
| Key | Meaning |
|---|---|
auto.restart_service | Services that may be restarted without asking. Anything not listed is escalated. |
auto.free_disk | Mount prefixes that may be cleaned without asking. |
auto.retry_upload | true to retry uploads automatically. |
ask.* | Tools that wait for a one-time code before they run. |
never.services | Protected services. Always blocked, even if also listed under auto. |
never.mounts | Protected mounts. Never cleaned. |
escalation.voice | Call the on-call phone if a page is not acknowledged in time. off to disable. |
escalation.quiet_hours | Only HIGH and CRITICAL pages go out during this window. |
escalation.approval.local_fallback | Allow approval from the local console when the phone can't be reached. Audited. |
Check and test
Validate the file, then replay last night's incidents against it to see what would have changed.
$ nightwatch policy check ok policy.yaml valid · 4 tools · 6 protected services $ nightwatch policy test --since 24h 88 incidents replayed · 2 would change lane · 0 protected targets touched