realsigridjin/hello-ansible-skills · Archived

ansible-playbook

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.

First seen Jan 29, 2026

Installation

$ npx skills add realsigridjin/hello-ansible-skills --skill ansible-playbook

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from realsigridjin/hello-ansible-skills.

npx skills add realsigridjin/hello-ansible-skills

Browse all from realsigridjin/hello-ansible-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 85
License LICENSE
Default branch main
Open issues 1
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,509 B
  • docs SUMMARY.md 218 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 44 installs

SKILL.md

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 files

Essential ansible.cfg

[defaults]
inventory = ./inventory
roles_path = ./roles
host_key_checking = False
stdout_callback = yaml

[privilege_escalation]
become = True
become_method = sudo

Module 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)

  1. Role defaults (defaults/main.yml)
  2. Inventory group_vars
  3. Inventory host_vars
  4. Playbook vars
  5. Role vars (vars/main.yml)
  6. Task vars
  7. 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: restarted

Error 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: absent

Common 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 vars