Ansible Playbook Writing and Review

VerifiedCaution

Assists in writing and reviewing Ansible playbooks, roles, and tasks following best practices for idempotency, security, and maintainability. Checks for proper use of FQCNs, handlers, error handling, and vault-encrypted secrets. Ideal for automating server configuration or reviewing existing Ansible code.

Sby Skills Guide Bot
DevOpsIntermediate
3/1/2026
Claude CodeCursorCodex
#ansible#configuration-management#infrastructure-as-code#idempotency#playbooks

Recommended for

Automated summary

Writes and reviews Ansible playbooks, roles, and tasks following best practices such as FQCNs, idempotency, handlers, and secret handling.

Strengths

  • Enforces concrete, checkable conventions: fully qualified collection names, a name on every task, explicit become
  • Ships reusable patterns for templated configs with validate, service restart handlers, and package installation
  • Includes a security checklist covering vault-encrypted secrets, no_log on sensitive tasks, and explicit file permissions

Limitations

  • Only relies on the generic modules shown (apt, service, template); no distro-specific or third-party collection guidance
  • Focused on authoring and static review, with no actual run or --check verification
  • No automated testing strategy (molecule, lint) beyond a note about check-mode compatibility
When to use it

When you need to author or audit an Ansible playbook that configures servers idempotently and securely.

When not to use it

When the task is cloud resource provisioning or Terraform/Kubernetes orchestration rather than Ansible configuration.

Security analysis

Caution
Quality score85/100

The content is a conventional Ansible style guide: it teaches FQCN usage, idempotency, handlers, vault for secrets, and explicitly forbids hardcoded secrets and unnecessary shell tasks. There is nothing destructive, obfuscated, or exfiltrating (no curl|sh, rm -rf, or secret transmission). The only reason it is not 'safe' is the broad allowed-tools set (Bash/Write/Edit), which is powerful but entirely appropriate for writing and validating playbooks.

Findings
  • •Declares Bash and Write/Edit access, which lets the agent execute commands and modify files on the host
  • •No explicit guardrails limiting Bash usage to check-mode/lint/read-only Ansible invocations
How this analysis is made

Examples

New playbook
Write an Ansible playbook that installs nginx and certbot on our webservers, deploys a config template, and restarts nginx only when the config changes.
Review existing role
Review roles/app/tasks/main.yml and flag anything that breaks our Ansible best practices — missing FQCNs, hardcoded secrets, non-idempotent shell commands.
Secrets handling
Refactor this playbook so the database password comes from an ansible-vault file and the task that writes it uses no_log.

name: ansible-playbook description: Write and review Ansible playbooks following best practices. Use when the user says "write ansible", "ansible playbook", "review playbook", "automate with ansible", or asks to configure servers with Ansible. allowed-tools: Read, Write, Edit, Glob, Grep, Bash

Ansible Playbook

Write and review Ansible playbooks, roles, and tasks following best practices.

Instructions

When writing:

  1. Understand the target configuration goal
  2. Check existing playbooks/roles for patterns to follow
  3. Write idempotent tasks with proper error handling
  4. Include appropriate tags and handlers

When reviewing:

  1. Read the playbook/role
  2. Check for issues listed below
  3. Suggest improvements

Playbook structure

---
- name: Configure web servers
  hosts: webservers
  become: true
  vars_files:
    - vars/main.yml
  handlers:
    - name: Restart nginx
      ansible.builtin.service:
        name: nginx
        state: restarted
  tasks:
    - name: Install nginx
      ansible.builtin.apt:
        name: nginx
        state: present
        update_cache: true
      notify: Restart nginx
      tags: [nginx, packages]

Best practices

  • MUST use FQCNs: ansible.builtin.copy not copy
  • MUST use name: for every task
  • MUST use become: explicitly, not assuming root
  • Use handlers for service restarts
  • Use block/rescue/always for error handling
  • Use ansible-vault for secrets
  • Use variables for anything environment-specific
  • Use --check mode compatible tasks where possible

Security checks

  • No plaintext passwords in playbooks
  • Secrets in vault-encrypted files
  • no_log: true on tasks with sensitive data
  • File permissions explicitly set
  • SSH keys not hardcoded

Common patterns

# Idempotent file content
- name: Configure app
  ansible.builtin.template:
    src: app.conf.j2
    dest: /etc/app/config
    mode: "0644"
    owner: app
    group: app
    validate: "/usr/bin/app --check %s"
  notify: Restart app

# Package installation
- name: Install packages
  ansible.builtin.apt:
    name: "{{ packages }}"
    state: present
  vars:
    packages:
      - nginx
      - certbot

Rules

  • MUST use fully qualified collection names (FQCNs)
  • MUST include task names
  • Never hardcode secrets in playbooks
  • Never use shell: when a module exists
  • Always make tasks idempotent

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/ansible-playbook-writing-and-review-mm78nocd/download' --output '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md.part' && mv '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md.part' '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Write, Edit, Glob, Grep, Bash

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md' && test -s '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/ansible-playbook' && cp -R '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd' '.claude/skills/ansible-playbook'

Cursor
test -f '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md' && test -s '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/ansible-playbook' && cp -R '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd' '.cursor/skills/ansible-playbook'

Codex
test -f '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md' && test -s '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/ansible-playbook' && cp -R '.skill-downloads/ansible-playbook-writing-and-review-mm78nocd' '.agents/skills/ansible-playbook'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/ansible-playbook-writing-and-review-mm78nocd'

openskills read 'ansible-playbook-writing-and-review-mm78nocd'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/ansible-playbook-writing-and-review-mm78nocd/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills