iac/ansible/roles/monitoring_agent/templates/security-metrics.json.j2
Sergei Poljanski 56dd0255dc
All checks were successful
deploy / ansible (push) Successful in 8m12s
monitoring: watch peers, devices, accounts and logins
Monitoring covered availability only: a new WireGuard peer, a machine
on the private network, an extra account or key, or a login from
outside the VPN would have gone unnoticed.

security-metrics runs every minute on both hosts and exports what it
finds for node_exporter: WireGuard peers and where they connect from,
addresses answering a ping sweep of the VPC, login accounts, sudo and
docker members, listening ports, containers with host-level access,
and fingerprints of the account, sudoers, sshd, WireGuard and
authorized_keys files. Each item is compared with a baseline in the
role defaults and host_vars and exported with known="true|false", so a
deliberate change has to update the baseline with it. On ops it also
counts Forgejo users, keys and runners.

Grafana gets a Security dashboard and an alert group for anything
unknown, a changed access file, an SSH login from outside WireGuard,
failed-login bursts on SSH, Forgejo, Grafana and the asxp.io admin, a
new container, and for logs or the collector itself going quiet, which
would otherwise blind the rest.

It never reads `wg show dump`, which prints preshared keys.

Assisted-by: Claude:fable-5-2
2026-11-15 21:59:16 +04:00

16 lines
613 B
Django/Jinja

{{ {
'textfile': monitoring_textfile_dir ~ '/security.prom',
'vpc_network': vpc_network,
'vpc_hosts': security_vpc_hosts,
'wg_peer_names': security_wg_peer_names,
'wg_peer_keys': security_wg_peer_keys,
'login_users': security_login_users + security_login_users_extra,
'groups': {
'sudo': security_sudo_users,
'docker': security_docker_users + security_docker_users_extra,
},
'ports': security_ports + security_ports_extra,
'containers': security_containers | combine(security_containers_extra),
'filesets': security_filesets,
'forgejo_db': security_forgejo_db,
} | to_nice_json }}