configuration-management-ansible
Skill1 starsChanged 4 months agoMITView on GitHub
Ansible configuration management: idempotent playbooks, role architecture, group_vars and host_vars layout, Jinja2 templating, Vault-encrypted variables, and check-mode verification. Use when applying a hardening or CIS baseline repeatably across many Ubuntu or RHEL hosts, refactoring a monolithic playbook into roles, or fixing a playbook that reports 'changed' on every run.
In this repository167 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/rules/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/00-index.mdcCursor rule
- .cursor/rules/skills/ai-agent-security-llm-threats.mdcCursor rule
- .cursor/rules/skills/api-gateway-service-mesh.mdcCursor rule
- .cursor/rules/skills/aws-cloud-migration-strategies.mdcCursor rule
- .cursor/rules/skills/aws-eks-enterprise-patterns.mdcCursor rule
- .cursor/rules/skills/aws-iam-zero-trust-policies.mdcCursor rule
- .cursor/rules/skills/azure-aks-enterprise-landing-zones.mdcCursor rule
- .cursor/rules/skills/azure-cloud-engineering-patterns.mdcCursor rule
- .cursor/rules/skills/backup-and-disaster-recovery.mdcCursor rule
- .cursor/rules/skills/chaos-engineering-resilience-testing.mdcCursor rule
- .cursor/rules/skills/cicd-pipeline-design.mdcCursor rule
- .cursor/rules/skills/cloud-native-microservices-patterns.mdcCursor rule
- .cursor/rules/skills/cloud-security-posture-cspm-cis.mdcCursor rule
- .cursor/rules/skills/configuration-management-ansible.mdcCursor rule
- .cursor/rules/skills/container-runtime-security-falco.mdcCursor rule
- .cursor/rules/skills/database-devops-lifecycle.mdcCursor rule
- .cursor/rules/skills/detection-engineering-threat-hunting.mdcCursor rule
- .cursor/rules/skills/devops-metrics-dora-kpis.mdcCursor rule
- .cursor/rules/skills/docker-containerization-basics.mdcCursor rule
- .cursor/rules/skills/enterprise-iac-governance-terragrunt.mdcCursor rule
- .cursor/rules/skills/finops-framework-inform-optimize-operate.mdcCursor rule
- .cursor/rules/skills/gcp-cloud-engineering-patterns.mdcCursor rule
- .cursor/rules/skills/gcp-gke-autopilot-multi-tenant.mdcCursor rule
- .cursor/rules/skills/git-branching-merge-strategies.mdcCursor rule
- .cursor/rules/skills/gitops-multi-cluster-argo-flux.mdcCursor rule
- .cursor/rules/skills/helm-kubernetes-deployment.mdcCursor rule
- .cursor/rules/skills/incident-management-and-postmortem.mdcCursor rule
- .cursor/rules/skills/infrastructure-host-monitoring.mdcCursor rule
- .cursor/rules/skills/internal-developer-portal-backstage.mdcCursor rule
- .cursor/rules/skills/linux-sysadmin-troubleshooting.mdcCursor rule
- .cursor/rules/skills/performance-load-testing.mdcCursor rule
- .cursor/rules/skills/policy-as-code-opa-kyverno.mdcCursor rule
- .cursor/rules/skills/prometheus-grafana-otel-tracing.mdcCursor rule
- .cursor/rules/skills/scalability-high-availability-patterns.mdcCursor rule
- .cursor/rules/skills/scripting-and-automation.mdcCursor rule
- .cursor/rules/skills/secops-incident-triage-forensics.mdcCursor rule
- .cursor/rules/skills/secrets-management-vault-kms.mdcCursor rule
- .cursor/rules/skills/serverless-event-driven-architecture.mdcCursor rule
- .cursor/rules/skills/shift-left-security-sast-sca.mdcCursor rule
- .cursor/rules/skills/sli-slo-error-budget-design.mdcCursor rule
- .cursor/rules/skills/supply-chain-security-slsa-sigstore.mdcCursor rule
- .cursor/rules/skills/terraform-iac-modules.mdcCursor rule
- .cursor/rules/skills/write-a-skill.mdcCursor rule
- .cursor/rules/skills/zero-downtime-release-strategies.mdcCursor rule
- ai-agent-security-llm-threatsSkill
- api-gateway-service-meshSkill
- aws-cloud-migration-strategiesSkill
- aws-eks-enterprise-patternsSkill
- aws-iam-zero-trust-policiesSkill
- azure-aks-enterprise-landing-zonesSkill
- azure-cloud-engineering-patternsSkill
- backup-and-disaster-recoverySkill
- chaos-engineering-resilience-testingSkill
- cicd-pipeline-designSkill
- cloud-native-microservices-patternsSkill
- cloud-security-posture-cspm-cisSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 75
Do: Always test playbooks with --check --diff in CI pipelines before deploying to production.
- Very specific: line 77
Don't: Never use the command or shell modules for tasks with native idempotent modules (like apt, yum, copy, template, file).
- Very specific: line 147
Run --tags cis --check --diff to produce a drift report against the CIS baseline without changing anything.
≈ “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
Declarative Configuration Management with Ansible
When to Use This Skill
Triggers — load this skill when:
- A fleet of VMs or bare-metal hosts needs repeatable configuration or hardening
- Playbooks are non-idempotent, monolithic, or untested in check mode
- Secrets in playbooks need to move to Ansible Vault or an external store
Route elsewhere when:
- Immutable infrastructure provisioning ->
terraform-iac-modules - Secret storage and dynamic credential issuance ->
secrets-management-vault-kms
1. Production Ansible Playbook Structure
---
- name: Hardened Node Baseline Configuration
hosts: all
become: true
gather_facts: true
vars:
ntp_servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
sysctl_network_optimizations:
net.ipv4.ip_forward: 0
net.ipv4.tcp_syncookies: 1
net.ipv4.conf.all.accept_redirects: 0
tasks:
- name: Apply security kernel sysctl settings
ansible.posix.sysctl:
name: "{{ item.key }}"
value: "{{ item.value }}"
state: present
reload: true
loop: "{{ sysctl_network_optimizations | dict2items }}"
- name: Ensure SSH daemon is securely configured
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: "^#?{{ item.key }}"
line: "{{ item.key }} {{ item.value }}"
state: present
validate: "/usr/sbin/sshd -t -f %s"
loop:
- { key: "PermitRootLogin", value: "no" }
- { key: "PasswordAuthentication", value: "no" }
- { key: "X11Forwarding", value: "no" }
notify: Restart SSH
handlers:
- name: Restart SSH
ansible.builtin.service:
name: sshd
state: restarted2. Best Practices & Anti-Patterns
- Do: Always test playbooks with
--check --diffin CI pipelines before deploying to production. - Do: Encrypt sensitive variables using
ansible-vault. - Don't: Never use the
commandorshellmodules for tasks with native idempotent modules (likeapt,yum,copy,template,file).
3. Role Architecture & Idempotency Enforcement
roles/baseline/
├── defaults/main.yml # Overridable defaults (lowest precedence)
├── vars/main.yml # Role-internal constants (high precedence)
├── tasks/main.yml # Entry point; import_tasks per concern
├── templates/sshd_config.j2 # Jinja2 templates
├── handlers/main.yml # Restart/reload handlers
└── meta/main.yml # Dependencies, supported platforms
inventories/prod/
├── hosts.ini
├── group_vars/web.yml # Per-group variables
└── host_vars/web-01.yml # Per-host overridesVariable precedence beats cleverness: put safe defaults in defaults/, environment
differences in group_vars/, and never duplicate the same value in both.
Jinja2 templating with a validation gate
- name: Render sshd config from template
ansible.builtin.template:
src: sshd_config.j2
dest: /etc/ssh/sshd_config
mode: "0600"
validate: "/usr/sbin/sshd -t -f %s" # bad render never lands
notify: Restart SSHForcing idempotency when a module does not exist
A playbook that reports changed on every run has no idempotency, so it cannot be used as a
drift detector. When command/shell is unavoidable, constrain it:
- name: Initialise the database schema exactly once
ansible.builtin.command: /usr/local/bin/init-schema.sh
args:
creates: /var/lib/app/.schema-initialised # skip if this exists
register: schema_init
changed_when: "'created' in schema_init.stdout"
failed_when: schema_init.rc not in [0, 2]Gate every change in CI with ansible-playbook --check --diff: a clean check run against
production is the proof that the fleet matches the code.
4. Mapping Roles to a CIS Baseline
Hardening tasks are only auditable when each one names the control it satisfies. Tag tasks with the CIS Benchmark control ID so a role doubles as evidence:
- name: CIS 5.2.4 — Ensure SSH X11 forwarding is disabled
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?X11Forwarding'
line: 'X11Forwarding no'
validate: "/usr/sbin/sshd -t -f %s"
tags: [cis, cis_5_2_4, ssh]Run --tags cis --check --diff to produce a drift report against the CIS baseline without
changing anything; run the same play without --check to remediate. Where a CIS control cannot
be applied (a legacy application needs an insecure setting), record it in the role's
defaults/main.yml as an explicit, commented exception with an owner rather than silently
dropping the task.
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.

