ansible-patterns

Provides production-tested Ansible playbook, role, vault, and inventory patterns with YAML and Jinja2 examples.

Updated Feb 25, 2026
One-click install
npx skills add https://github.com/HermeticOrmus/LibreDevOps-Claude-Code --skill ansible-patterns-hermeticormus
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ansible-patterns
Source: https://github.com/HermeticOrmus/LibreDevOps-Claude-Code/tree/main/plugins/ansible-automation/skills/ansible-patterns
Command: npx skills add https://github.com/HermeticOrmus/LibreDevOps-Claude-Code --skill ansible-patterns-hermeticormus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Ansible automation that is idempotent, secure, and maintainable is hard; ad-hoc playbooks often break under production conditions, leak secrets, or cause unnecessary downtime during deployments. ## Core Features & Use Cases - Playbook and Role Patterns: Ready-to-adapt site.yml orchestration with rolling updates (serial, max_fail_percentage), load balancer drain/re-enable hooks, and a complete role directory layout including Molecule tests. - Secrets and Inventory Management: Ansible Vault workflows (encrypt_string, vault IDs per environment) and dynamic AWS EC2 inventory configuration with tag-based grouping. - Idempotency and Error Handling: changed_when/failed_when patterns, block/rescue/always rollback structures, and handler-based zero-downtime reloads. - Use Case: A DevOps engineer needs to deploy a web application across 50 EC2 instances with rolling updates, encrypted database credentials, and automatic rollback on health-check failure; this Skill provides the exact playbook structure, vault setup, and rescue blocks to implement it. ## Quick Start Ask the AI to generate an Ansible playbook with rolling deployment, vault-encrypted secrets, and rollback handling based on these Ansible patterns.

Frequently Asked Questions about ansible-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure an Ansible playbook for rolling deployments?▼

Use serial with a percentage (e.g., serial: "25%") and max_fail_percentage to batch updates, combined with pre_tasks to remove hosts from the load balancer and post_tasks to health-check and re-enable them. This pattern limits blast radius while maintaining availability.

How to encrypt secrets in Ansible with vault?▼

Use ansible-vault encrypt_string to encrypt individual values inline, or ansible-vault encrypt for entire vars files. Reference encrypted variables like vault_db_password in plain vars files, and pass credentials at runtime with --vault-password-file or --vault-id per environment.

How do I make Ansible command tasks idempotent?▼

Register the command output and set changed_when: false for read-only checks, use the creates argument for one-time initialization, and define failed_when conditions for custom error detection. Avoid raw command or shell for package and service management where dedicated modules exist.

Does Ansible support dynamic AWS EC2 inventory?▼

Yes, the amazon.aws.aws_ec2 inventory plugin generates hosts from EC2 instances across regions, groups them by tags like Environment and Role via keyed_groups, and filters by instance state. Configure it in an aws_ec2.yml inventory file with hostnames and connection variables.

How do I test Ansible roles with Molecule?▼

Define a molecule.yml with the docker driver and platform images such as Ubuntu 22.04 or Rocky Linux 9, then write a verify.yml playbook asserting service state, HTTP responses, and config validity. Run ansible-lint in the lint step for style enforcement.

What are common Ansible anti-patterns to avoid?▼

Avoid using command or shell where modules exist (e.g., apt instead of apt-get), restarting services in tasks instead of handlers, hardcoded IPs instead of inventory variables, broad ignore_errors: true, and plaintext secrets files instead of vault encryption.