Skip to content
Back to skills

Ansible

ASecurity

Ansible automation and configuration management patterns. Use when writing Ansible playbooks, roles, or automating infrastructure configuration and deployment tasks.

  • 15 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added May 27, 2026
devopsgo

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add jpoutrin/product-forge --skill ansible --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ansible?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ansible
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jpoutrin-ansible/badge)](https://www.skillsdirectory.com/skills/jpoutrin-ansible)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ansible
description: Ansible automation and configuration management patterns. Use when writing Ansible playbooks, roles, or automating infrastructure configuration and deployment tasks.
user-invocable: false
---

# Ansible Skill

This skill provides Ansible automation patterns and best practices.

## Playbook Structure

```yaml
---
- name: Configure web servers
  hosts: webservers
  become: true
  vars:
    http_port: 80

  tasks:
    - name: Install nginx
      ansible.builtin.apt:
        name: nginx
        state: present
      notify: Restart nginx

  handlers:
    - name: Restart nginx
      ansible.builtin.service:
        name: nginx
        state: restarted
```

## Role Structure

```
roles/
└── webserver/
    ├── defaults/main.yml    # Default variables
    ├── handlers/main.yml    # Handler definitions
    ├── tasks/main.yml       # Task list
    ├── templates/           # Jinja2 templates
    ├── files/               # Static files
    └── vars/main.yml        # Role variables
```

## Best Practices

### Use Fully Qualified Collection Names
```yaml
# ✅ Good
- ansible.builtin.apt:
    name: nginx

# ❌ Bad (ambiguous)
- apt:
    name: nginx
```

### Idempotent Tasks
```yaml
# Tasks should be safe to run multiple times
- name: Ensure config exists
  ansible.builtin.template:
    src: config.j2
    dest: /etc/app/config.yml
  # Only changes if content differs
```

### Use Handlers for Service Restarts
```yaml
tasks:
  - name: Update config
    template:
      src: nginx.conf.j2
      dest: /etc/nginx/nginx.conf
    notify: Restart nginx

handlers:
  - name: Restart nginx
    service:
      name: nginx
      state: restarted
```

## Inventory Best Practices

```ini
[webservers]
web1.example.com
web2.example.com

[dbservers]
db1.example.com

[production:children]
webservers
dbservers
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.