Ansible automation workflow guidelines. Activate when working with Ansible playbooks, ansible-playbook, inventory files (.yml, .ini), or Ansible-specific patterns.
Instalación
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Ansible automation workflow guidelines. Activate when working with Ansible playbooks, ansible-playbook, inventory files (.yml, .ini), or Ansible-specific patterns.
location
user
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
Ansible Workflow
Tool Grid
Task
Tool
Command
Lint
ansible-lint
ansible-lint
YAML lint
yamllint
yamllint .
Syntax check
ansible
ansible-playbook --syntax-check
Dry run
ansible
ansible-playbook --check
Run
ansible
ansible-playbook playbook.yml
Test roles
molecule
molecule test
Encrypt
sops
sops -e secrets.yml
Decrypt
sops
sops -d secrets.yml
Runtime Requirements
Ansible Core 2.18+ with Python 3.12+
ansible-lint and yamllint installed
SOPS for secrets management (RECOMMENDED over ansible-vault for GitOps)
Molecule + docker driver for role testing
Code Standards
FQCN Requirement
All module names MUST use Fully Qualified Collection Names (FQCN):
# CORRECT-name:Copyconfigurationfileansible.builtin.copy:src:app.confdest:/etc/app/app.conf# INCORRECT - DO NOT USE-name:Copyconfigurationfilecopy:src:app.confdest:/etc/app/app.conf
Linting
All playbooks and roles MUST pass linting before commit:
# Run both linters
ansible-lint && yamllint .
Configuration templates available in assets/:
.ansible-lint.template - Production profile with strict mode
.yamllint.template - YAML linting with 120 char lines
Sensitive Data
Tasks handling sensitive data MUST use no_log: true:
roles/
├── nginx/ # Web server only
├── ssl_certificates/ # SSL management only
├── postgresql/ # Database only
└── app_deploy/ # Application deployment only
Handlers execute in definition order, not notification order. Define handlers in logical sequence (validate -> reload -> restart).
Variable Precedence
Ansible variable precedence (highest to lowest):
Extra vars (-e "var=value")
Task vars (in task definition)
Block vars
Role and include vars
Set facts / registered vars
Play vars_files
Play vars
Host facts
Playbook host_vars
Inventory host_vars
Playbook group_vars
Inventory group_vars
Role defaults
Best Practices
# Use role defaults for safe defaults# roles/nginx/defaults/main.ymlnginx_worker_processes:autonginx_worker_connections:1024# Use group_vars for environment-specific overrides# group_vars/prod/nginx.ymlnginx_worker_connections:4096# Use extra vars for one-time overrides onlyansible-playbookplaybook.yml-e"nginx_worker_connections=8192"
molecule test# Full test cycle
molecule converge # Apply role
molecule verify # Run verification
molecule destroy # Cleanup
Performance Optimization
ansible.cfg Settings
Use the template at assets/ansible.cfg.template:
forks = 20 - Parallel execution
pipelining = True - Reduce SSH operations
gathering = smart - Cache facts
fact_caching = jsonfile - Persist facts
Task Optimization
# Use async for long-running tasks-name:Upgradeallpackagesansible.builtin.dnf:name:"*"state:latestasync:600poll:10# Use free strategy for independent tasks-hosts:allstrategy:freetasks:-name:Independenttask1ansible.builtin.command:/opt/script1.sh-name:Independenttask2ansible.builtin.command:/opt/script2.sh