ansible-hardening
Skill1 starsChanged 5 months agoMITView on GitHub
Codify security hardening into reusable Ansible roles — CrowdSec IDS, fail2ban, auditd, Tailscale VPN, Semaphore UI, scoped sudoers, systemd sandboxing, and UFW firewall management. Trigger on: "harden with Ansible", "Ansible security", "CrowdSec role", "fail2ban role", "auditd role", "Tailscale Ansible", "Semaphore role", "sudoers role", "security playbook", "fleet hardening", or any request to automate security configurations that were done manually.
In this repository32 other files it gives its agents.
- budi-analyticsSkill
- claude-to-cursorSkill
- code-consistencySkill
- code-qualitySkill
- config-auditorSkill
- container-sandboxSkill
- cost-optimizerSkill
- cpa-tax-specialistSkill
- database-designSkill
- differential-reviewSkill
- fleet-managerSkill
- grill-meSkill
- hydra-swarmSkill
- inbound-syncSkill
- infosec-architectSkill
- insecure-defaultsSkill
- model-evaluationSkill
- modern-pythonSkill
- ms-office-suiteSkill
- openclaw-opsSkill
- prd-to-planSkill
- project-managementSkill
- property-based-testingSkill
- session-miserSkill
- session-miserSkill
- skill-updaterSkill
- supply-chain-risk-auditorSkill
- systematic-debuggingSkill
- tddSkill
- token-miserSkill
- verification-before-completionSkill
- write-a-prdSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 92
Always --check --diff before real runs
- Distinctive: line 93
Never remove existing security controls — only add/tighten
- Distinctive: line 96
Test on a primary host first, then roll to fleet
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Ansible Hardening
Codify manual security work into idempotent Ansible roles. Every hardening step performed by hand should eventually become a role in this collection.
Roles Needed (from manual work done 2026-03-21)
crowdsec
Installs CrowdSec agent + firewall bouncer, configures collections, whitelists LAN.
# defaults
crowdsec_lapi_port: 8088 # moved from 8080 for OpenShell
crowdsec_collections:
- crowdsecurity/sshd
- crowdsecurity/linux
crowdsec_whitelist_cidrs:
- "{{ lan_subnet }}"fail2ban
Installs fail2ban, configures SSH jail.
# defaults
fail2ban_maxretry: 3
fail2ban_bantime: 3600
fail2ban_findtime: 600auditd
Installs auditd, deploys audit rules for sensitive files.
# defaults
auditd_watch_paths:
- { path: /etc/sudoers, key: sudoers_changes }
- { path: /etc/sudoers.d/, key: sudoers_changes }
- { path: /etc/ssh/sshd_config, key: ssh_config }
- { path: /etc/monero/, key: monero_config }tailscale
Installs Tailscale, configures serve endpoints.
# defaults
tailscale_serve_ports: [] # list of {local_port, description}
tailscale_funnel: false # never enable funnel by defaultNote: tailscale up requires interactive auth — role should detect and prompt.
semaphore
Installs Semaphore binary, creates config + systemd unit.
# defaults
semaphore_version: "2.17.27"
semaphore_port: 3001
semaphore_bind: "127.0.0.1"
semaphore_db: bolt # bolt or postgressudoers-scope
Replaces blanket NOPASSWD with scoped command list.
# defaults
sudoers_nopasswd_commands:
- /usr/bin/systemctl
- /usr/bin/journalctl
- /usr/bin/apt
- /usr/bin/apt-get
# ... full list from /etc/sudoers.d/admin_userImplementation Pattern
Each role follows monero-farm conventions:
defaults/main.yml— all variables with safe defaultstasks/main.yml— idempotent taskshandlers/main.yml— restart/reload handlerstemplates/— config file templates (Jinja2)
Rules
- Always
--check --diffbefore real runs - Never remove existing security controls — only add/tighten
- Whitelist LAN subnet before enabling firewall bouncers
- Tailscale auth is interactive — can't be fully automated
- Test on a primary host first, then roll to fleet
Where To Build
These roles belong in your project's ansible/roles/ directory alongside existing
roles (base, application-specific, monitoring). The security roles extend
the base role's hardening.
Alternatively, create a standalone ansible-hardening collection at
<your-repo-root>/ansible-hardening/ if the scope grows and needs to be reused
across multiple projects.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

