← スキル一覧に戻る

ansible
by cbeauhilton
⭐ 0🍴 0📅 2026年1月22日
SKILL.md
name: Ansible version: 1.0.0 description: Infrastructure automation for Proxmox lab services. USE WHEN deploying services, configuring VMs/LXCs, managing Docker stacks, or automating lab infrastructure.
Ansible - Infrastructure as Code for Lab Services
Declarative service deployment. Ansible manages your Proxmox lab - VMs, LXCs, Docker stacks, NFS mounts, and secrets.
Your Lab Pattern
Every service follows the same structure:
<service>/
├── ansible/
│ ├── playbook.yml # Main entrypoint
│ ├── inventory.yml # Target hosts
│ ├── vars.yml # Service-specific variables (optional)
│ ├── vault.yml # Encrypted secrets (optional)
│ ├── files/ # Static files (docker-compose.yml, configs)
│ ├── templates/ # Jinja2 templates (.j2)
│ └── roles/ # Reusable role (optional)
│ └── <service>/
│ ├── tasks/main.yml
│ ├── handlers/main.yml
│ └── files/
└── terraform/ # VM/LXC provisioning (if applicable)
Run from service directory:
cd /home/beau/src/personal/lab/<service>
ansible-playbook -i ansible/inventory.yml ansible/playbook.yml
Philosophy: Idempotent by Default
Ansible's power is idempotency - run it once or 100 times, same result.
Good (idempotent):
- name: Ensure Docker is installed
apt:
name: docker-ce
state: present # Only installs if missing
Bad (not idempotent):
- name: Install Docker
shell: curl -fsSL https://get.docker.com | sh # Runs every time
If you MUST use shell/command, add creates: or when: guards:
- name: Initialize something
shell: /opt/init.sh
args:
creates: /opt/.initialized # Skip if file exists
Common Patterns
1. Docker Stack Deployment
Your standard pattern for services like arr, kestra, immich:
- name: Deploy {{ service_name }}
hosts: service
become: yes
tasks:
- name: Create app directory
file:
path: /opt/{{ service_name }}
state: directory
owner: ansible
group: ansible
- name: Deploy docker-compose.yml
copy:
src: files/docker-compose.yml
dest: /opt/{{ service_name }}/docker-compose.yml
- name: Start services
community.docker.docker_compose_v2:
project_src: /opt/{{ service_name }}
state: present
pull: always
2. NFS Mount (from Proxmox ZFS)
- name: Mount NFS share
mount:
path: /mnt/media
src: "10.0.0.42:/tank/media"
fstype: nfs
state: mounted
opts: defaults,_netdev
3. Vault for Secrets
# Create encrypted vault
ansible-vault create ansible/vault.yml
# Edit existing vault
ansible-vault edit ansible/vault.yml
# Run playbook with vault
ansible-playbook -i ansible/inventory.yml ansible/playbook.yml --ask-vault-pass
In playbook:
pre_tasks:
- name: Load vault secrets
include_vars:
file: vault.yml
ignore_errors: yes
no_log: yes
4. Health Check Pattern
- name: Wait for service to be ready
uri:
url: http://localhost:8080
status_code: [200, 302, 401]
register: service_ready
until: service_ready.status in [200, 302, 401]
retries: 30
delay: 5
failed_when: false
Inventory Patterns
Single Host
all:
hosts:
service:
ansible_host: 10.0.0.155
ansible_user: ansible
ansible_become: yes
Multi-Host with Groups
all:
children:
proxmox:
hosts:
pve:
ansible_host: 10.0.0.42
services:
hosts:
arr:
ansible_host: 10.0.0.155
kestra:
ansible_host: 10.0.0.153
Quick Command Reference
# Dry run (check mode)
ansible-playbook -i inventory.yml playbook.yml --check
# Run specific tags
ansible-playbook -i inventory.yml playbook.yml --tags "docker,deploy"
# Limit to specific host
ansible-playbook -i inventory.yml playbook.yml --limit "arr"
# Extra variables
ansible-playbook -i inventory.yml playbook.yml -e "service_version=2.0"
# Verbose output
ansible-playbook -i inventory.yml playbook.yml -vvv
Context Files
Philosophy.md- Deep dive on idempotency, roles vs inline, when to abstractPatterns.md- Your lab-specific patterns, Docker, NFS, Proxmox integrationReference.md- Module quick reference for common tasks
Decision Tree
What are you automating?
│
├─→ New service? → Copy template-vm or template-lxc structure
│
├─→ Single playbook task? → Inline in playbook.yml
│
├─→ Reusable across services? → Extract to role
│
└─→ Secrets involved? → Use vault.yml + include_vars
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です