Ansible role to deploy egress-auditor, a tool that monitors outbound TCP and UDP connections and generates firewall rules or logs.
community.generalcollection (for thecapabilitiesmodule)- Target must be a Linux system with netfilter support
| Variable | Default | Description |
|---|---|---|
egress_auditor_version |
v0.1.1 |
Release tag to download |
egress_auditor_arch |
auto-detected | Binary architecture (amd64, arm64, 386). Auto-mapped from ansible_architecture |
egress_auditor_bin_path |
/usr/local/bin/egress-auditor |
Install path for the binary |
egress_auditor_input |
nflog |
Input plugin |
egress_auditor_input_options |
["nflog:group:100"] |
List of -I flags passed to egress-auditor |
egress_auditor_output |
logfmt |
Output plugin (logfmt, iptables, loki) |
egress_auditor_output_options |
[] |
List of -O flags passed to egress-auditor |
egress_auditor_extra_args |
"" |
Extra CLI arguments (e.g. -R to hide process name) |
egress_auditor_user |
root |
User to run the service as |
egress_auditor_setcap |
true |
Set cap_net_admin capability on the binary |
egress_auditor_nflog_group |
100 |
NFLOG group ID for the nftables rule |
egress_auditor_nflog_manage_rules |
true |
Deploy nftables rules to log new outbound TCP and UDP connections |
egress_auditor_nflog_chain_priority |
10 |
nftables chain priority (runs after standard filter chains at priority 0) |
egress_auditor_nflog_bypass_rules |
[] |
List of nftables accept rules applied before NFLOG (matched packets are silently accepted, not logged) |
egress_auditor_logrotate |
true when output is logfmt |
Deploy a logrotate configuration |
egress_auditor_logfile |
/var/log/egress-auditor.log |
Log file path (used by logrotate) |
egress_auditor_logrotate_frequency |
daily |
Logrotate frequency |
egress_auditor_logrotate_rotate |
14 |
Number of rotated files to keep |
- Downloads the egress-auditor binary from GitHub releases
- Sets
cap_net_admincapability on the binary (whenegress_auditor_setcapis true) - Deploys a systemd unit file and enables/starts the service
- Deploys nftables rules in a dedicated
inet egress_auditortable to log new outbound TCP and UDP connections via NFLOG (when using thenfloginput plugin andegress_auditor_nflog_manage_rulesis true). Rules are written to/etc/nftables.d/egress-auditor.nftand loaded withnft -f. - Deploys a logrotate configuration that sends SIGHUP to trigger log file reopen (when using the
logfmtoutput plugin)
- hosts: servers
roles:
- role: ansible-egress-auditor
egress_auditor_output: logfmt
egress_auditor_output_options:
- "logfmt:file:/var/log/egress-auditor.log"- hosts: servers
roles:
- role: ansible-egress-auditor
egress_auditor_output: iptables
egress_auditor_output_options:
- "iptables:verbose:2"- hosts: servers
roles:
- role: ansible-egress-auditor
egress_auditor_output: logfmt
egress_auditor_output_options:
- "logfmt:file:/var/log/egress-auditor.log"
egress_auditor_nflog_bypass_rules:
- "tcp dport { 80, 443 } accept"
- "ip daddr 10.0.0.0/8 accept"- hosts: servers
roles:
- role: ansible-egress-auditor
egress_auditor_output: loki
egress_auditor_output_options:
- "loki:url:http://loki.example.com:3100"
- "loki:labels:host={{ inventory_hostname }}"MIT