crowdsec: host sshd + Gitea logs, nftables firewall bouncer (SSH bans only for now), weekly hub update

- crowdsec image -> latest-debian (journalctl); reads host journal (sshd)
  and Gitea's log file (LePresidente/gitea); LAPI on 127.0.0.1:8080
- gitea also logs to /data/gitea/log/gitea.log (router lines console only)
- host: crowdsec-firewall-bouncer-nftables from packagecloud any/any, own
  nft tables on input+forward hooks; limited to local ssh detections and
  manual bans until crowdsec_firewall_all_decisions
- weekly cscli hub update/upgrade + SIGHUP

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PhilandClaude Opus 5.5 committed 2026-11-27 13:26:00 -07:00
1 parent fa0060523f
commit 41e9428412
10 files changed
+128 -5

No files matched your search

@@ -0,0 +1,39 @@
# CrowdSec firewall bouncer (nftables) on the host. It reads decisions from
# the crowdsec container's LAPI (127.0.0.1:8080). If it stops, its tables go
# away (nothing is blocked); it never touches ufw's or Docker's rules.
# packagecloud has no trixie dist, so use the generic any/any repo.
- name: crowdsec apt repository
ansible.builtin.deb822_repository:
name: crowdsec
types: deb
uris: https://packagecloud.io/crowdsec/crowdsec/any
suites: any
components: main
signed_by: https://packagecloud.io/crowdsec/crowdsec/gpgkey
# Written before the package: its postinst starts the service right away.
- name: crowdsec bouncer config directory
ansible.builtin.file:
path: /etc/crowdsec/bouncers
state: directory
mode: '0755'
- name: firewall bouncer config overrides
ansible.builtin.template:
src: crowdsec-firewall-bouncer.yaml.local.j2
dest: /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml.local
owner: root
mode: '0600'
diff: false # contains the bouncer key
notify: restart crowdsec-firewall-bouncer
- name: install the nftables firewall bouncer
ansible.builtin.apt:
name: crowdsec-firewall-bouncer-nftables
update_cache: true
- name: firewall bouncer running
ansible.builtin.systemd_service:
name: crowdsec-firewall-bouncer
state: started
enabled: true
+18 -1
View File
@@ -29,7 +29,7 @@
dest: "/opt/stacks/crowdsec/acquis.d/{{ item }}.yaml"
owner: root
mode: '0644'
loop: [caddy, appsec]
loop: [caddy, appsec, sshd, gitea]
notify: restart crowdsec
- name: deploy crowdsec stack
@@ -66,3 +66,20 @@
when: >-
not ansible_check_mode and
(crowdsec_allowlist_current.rc != 0 or item not in crowdsec_allowlist_current.stdout)
# The entrypoint only updates hub items (parsers, scenarios, vpatch rules) on
# start; dockcheck restarts crowdsec only when a new image ships.
- name: weekly crowdsec hub update
ansible.builtin.cron:
name: crowdsec hub upgrade
weekday: "1"
hour: "4"
minute: "17"
user: root
job: >-
docker exec crowdsec cscli hub update >/dev/null &&
docker exec crowdsec cscli hub upgrade >/dev/null &&
docker kill -s HUP crowdsec >/dev/null
- name: firewall bouncer on the host
ansible.builtin.import_tasks: crowdsec-firewall-bouncer.yml