ansible-playbook
Skill89 starsChanged 10 months agoMITView on GitHub
Use when creating playbooks, roles, or inventory files. Use when automating infrastructure with Ansible. Use when encountering YAML syntax errors, module failures, or variable precedence issues.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- ai-workspace-lab/xworkspace-core-skillstheir own version, first seen Nov 15, 2026
- nordz0r/skillstheir own version, first seen Oct 15, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- ai-workspace-lab/xworkspace-core-skills★ 8same name
- nordz0r/skills★ 8same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- ansible-convertSkill
- ansible-debugSkill
- ansible-interactiveSkill
The file
Files
Ansible Playbook Development
Overview
Ansible playbooks declare desired system state rather than imperative commands. The core principle is idempotency: running a playbook multiple times produces the same result without unintended changes.
When to Use
- Creating new playbooks or roles
- Writing inventory files
- Debugging YAML syntax errors
- Troubleshooting module parameter issues
- Understanding variable precedence
- Converting shell scripts to Ansible
Quick Reference
Project Structure
project/
├── ansible.cfg # Configuration
├── inventory # Host definitions
├── group_vars/ # Group variables
├── host_vars/ # Host-specific vars
├── roles/ # Reusable roles
└── playbooks/ # Playbook filesEssential ansible.cfg
[defaults]
inventory = ./inventory
roles_path = ./roles
host_key_checking = False
stdout_callback = yaml
[privilege_escalation]
become = True
become_method = sudoModule Patterns
| Operation | Module | Key Parameters |
| Create directory | ansible.builtin.file | state: directory, mode, owner |
| Copy file | ansible.builtin.copy | src, dest, mode |
| Template | ansible.builtin.template | src, dest, variables in .j2 |
| Install package | ansible.builtin.package | name, state: present |
| Manage service | ansible.builtin.service | name, state, enabled |
| Run command | ansible.builtin.command | cmd, register result, set changed_when |
Variable Precedence (lowest to highest)
- Role defaults (
defaults/main.yml) - Inventory group_vars
- Inventory host_vars
- Playbook vars
- Role vars (
vars/main.yml) - Task vars
- Extra vars (
-e)
Handlers
tasks:
- name: Update config
ansible.builtin.template:
src: app.conf.j2
dest: /etc/app.conf
notify: Restart app
handlers:
- name: Restart app
ansible.builtin.service:
name: app
state: restartedError Handling
- block:
- name: Risky operation
ansible.builtin.command: /opt/app/upgrade.sh
rescue:
- name: Handle failure
ansible.builtin.debug:
msg: "Upgrade failed, rolling back"
always:
- name: Cleanup
ansible.builtin.file:
path: /tmp/upgrade.lock
state: absentCommon Mistakes
| Mistake | Fix |
| Using short module names | Always use FQCN: ansible.builtin.copy not copy |
| Hardcoded values | Extract to variables in defaults/main.yml |
Missing changed_when on commands | Add changed_when: "'created' in result.stdout" |
| Forgetting handler flush | Use meta: flush_handlers when needed before dependent tasks |
| YAML indentation errors | Use 2 spaces, never tabs |
| Colon in unquoted string | Quote values containing : |
Verification Commands
ansible-playbook --syntax-check playbook.yml # Check YAML
ansible-playbook --check playbook.yml # Dry run
ansible-playbook --check --diff playbook.yml # Show file changes
ansible-inventory --list # Verify inventory
ansible-inventory --host hostname # Check host varsDoes 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.

