← ClaudeAtlas

ansible-patternslisted

When to activate: Ansible, playbook, inventory, role, handler, template, vault, task, module, idempotent
Mattakushi432/Claude-Code-Skills-Custom-DevTools-Pack · ★ 0 · AI & Automation · score 73
Install: claude install-skill Mattakushi432/Claude-Code-Skills-Custom-DevTools-Pack
# Ansible Patterns ## Directory Structure (roles) ``` site.yml inventory/ production/ hosts group_vars/ all.yml webservers.yml staging/ hosts roles/ webserver/ tasks/ main.yml handlers/ main.yml templates/ nginx.conf.j2 vars/ main.yml defaults/ main.yml meta/ main.yml ``` ## Inventory (ini) ```ini [webservers] web1.example.com ansible_user=ubuntu web2.example.com ansible_user=ubuntu [databases] db1.example.com ansible_user=ubuntu [all:vars] ansible_python_interpreter=/usr/bin/python3 ``` ## Playbook ```yaml --- - name: Configure web servers hosts: webservers become: true vars_files: - vars/secrets.yml roles: - common - webserver tasks: - name: Ensure nginx is latest ansible.builtin.package: name: nginx state: latest notify: Restart nginx ``` ## Handlers ```yaml # roles/webserver/handlers/main.yml --- - name: Restart nginx ansible.builtin.service: name: nginx state: restarted - name: Reload nginx ansible.builtin.service: name: nginx state: reloaded ``` ## Jinja2 Template (nginx.conf.j2) ```nginx server { listen 80; server_name {{ server_name }}; root {{ document_root }}; location / { proxy_pass http://{{ upstream_host }}:{{ upstream_port }}; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } {% if enable_ssl %} listen 443 ssl;