Adversarial parity review of every ported action against its bash source confirmed 17 real behavioral drifts (of 22 claimed); all fixed here: - tiers/chown: defaults were compositions/apex/tierN (one level too deep); now the tier roots. shared/ base reset is non-recursive again. - compose: --dry-run was swallowed by argparse.REMAINDER; now stripped. - host.write_file: rendered files land 0644 (tempfile's 0600 made fresh systemd units/crowdsec configs owner-only). - systemd.deploy_units: top-level non-hidden files only. - ufw: missing docker/host config dir exits 66; missing /etc/ufw target aborts; empty rules dir warns; dotfile .rules excluded. - sync/packages: Telegram error-trap parity and failed notify exits 1. Same notify-failure exit for backup/run and sync/repository. repository regains the node-dir guard. - tiers/useradd: no more secret-bearing .env.bak per run. - tiers/link: EOF on confirm prompt declines and continues. - extract-traefik-certs: sudo mkdir inside the notify envelope. - generate-happ-subscriptions: realpath parent-exists guards + docker check. - configure/crowdsec: bouncer install goes through install_packages. - lint-docker-compose: malformed/unreadable anchor-IP inputs are lint errors. - core compose: APEX_RESTIC_REPOSITORY now ?error; RESTIC_COMPRESSION per-node via APEX_RESTIC_COMPRESSION (default auto). - sys.service_exists line-anchored; tpl docstring corrected.
25 lines
1.2 KiB
Python
25 lines
1.2 KiB
Python
# actions/configure/crowdsec.py
|
|
"""Port of configure/crowdsec — install, deploy /etc/crowdsec, collections, bouncer."""
|
|
import os
|
|
from engine.descriptor import Meta, Flag
|
|
|
|
METADATA = Meta(summary="Install + configure CrowdSec from configs/crowdsec.",
|
|
args=[Flag("--dry-run", "Render only; do not write/reload.")])
|
|
|
|
def run(ctx, args):
|
|
cfg = os.path.join(ctx.paths.configs, "crowdsec")
|
|
if not os.path.isdir(cfg):
|
|
ctx.log.error(f"Config directory not found: {cfg}"); raise SystemExit(1)
|
|
ctx.log.info("Configuring CrowdSec...")
|
|
if not args.dry_run:
|
|
ctx.crowdsec.ensure_installed()
|
|
ctx.crowdsec.deploy("crowdsec", ctx.vars(), dry_run=args.dry_run)
|
|
if not args.dry_run:
|
|
ctx.crowdsec.install_collections(["crowdsecurity/linux", "crowdsecurity/traefik"])
|
|
bouncer = os.path.join(cfg, "bouncers", "crowdsec-firewall-bouncer.yaml.local")
|
|
if os.path.isfile(bouncer) and not ctx.sys.ok(
|
|
["bash", "-c", "dpkg -l | grep -q crowdsec-firewall-bouncer-iptables"]):
|
|
ctx.log.info("Installing crowdsec-firewall-bouncer-iptables...")
|
|
ctx.sys.install_packages(["crowdsec-firewall-bouncer-iptables"])
|
|
ctx.log.success("Configured crowdsec.")
|