โ† Back to list
armanzeroeight

inventory-manager

by armanzeroeight

๐Ÿš€ A collection of Claude subagents, skills, rules, guides, and blueprints for Developers, Engineers, and Creators. | Covering programming languages, DevOps, Cloud, and beyond.

โญ 20๐Ÿด 4๐Ÿ“… Jan 18, 2026

SKILL.md


name: inventory-manager description: Organizes Ansible inventory files, manages host groups, and configures dynamic inventory. Use when organizing Ansible inventory, managing host groups, or setting up dynamic inventory sources.

Inventory Manager

Quick Start

Organize Ansible inventory with proper host groups, variables, and dynamic inventory sources.

Instructions

Step 1: Create static inventory

INI format:

# inventory/production
[webservers]
web1 ansible_host=192.168.1.10
web2 ansible_host=192.168.1.11

[databases]
db1 ansible_host=192.168.1.20
db2 ansible_host=192.168.1.21

[loadbalancers]
lb1 ansible_host=192.168.1.30

[production:children]
webservers
databases
loadbalancers

[production:vars]
ansible_user=deploy
ansible_python_interpreter=/usr/bin/python3
environment=production

YAML format:

# inventory/production.yml
all:
  children:
    production:
      children:
        webservers:
          hosts:
            web1:
              ansible_host: 192.168.1.10
            web2:
              ansible_host: 192.168.1.11
        databases:
          hosts:
            db1:
              ansible_host: 192.168.1.20
            db2:
              ansible_host: 192.168.1.21
        loadbalancers:
          hosts:
            lb1:
              ansible_host: 192.168.1.30
      vars:
        ansible_user: deploy
        environment: production

Step 2: Organize group variables

Directory structure:

inventory/
โ”œโ”€โ”€ production
โ”œโ”€โ”€ staging
โ”œโ”€โ”€ group_vars/
โ”‚   โ”œโ”€โ”€ all.yml
โ”‚   โ”œโ”€โ”€ webservers.yml
โ”‚   โ”œโ”€โ”€ databases.yml
โ”‚   โ””โ”€โ”€ production.yml
โ””โ”€โ”€ host_vars/
    โ”œโ”€โ”€ web1.yml
    โ””โ”€โ”€ db1.yml

group_vars/all.yml:

---
# Variables for all hosts
ansible_python_interpreter: /usr/bin/python3
ntp_servers:
  - 0.pool.ntp.org
  - 1.pool.ntp.org

group_vars/webservers.yml:

---
# Variables for webservers group
nginx_port: 80
nginx_worker_processes: 4
app_directory: /var/www/app

group_vars/production.yml:

---
# Variables for production environment
environment: production
backup_enabled: true
monitoring_enabled: true

Step 3: Configure host-specific variables

host_vars/web1.yml:

---
nginx_worker_connections: 1024
server_id: 1

Step 4: Use inventory in playbooks

# Run playbook with specific inventory
ansible-playbook -i inventory/production site.yml

# Target specific group
ansible-playbook -i inventory/production site.yml --limit webservers

# Target specific host
ansible-playbook -i inventory/production site.yml --limit web1

Dynamic Inventory

AWS EC2 Plugin

inventory/aws_ec2.yml:

---
plugin: amazon.aws.aws_ec2
regions:
  - us-east-1
  - us-west-2

filters:
  tag:Environment: production
  instance-state-name: running

keyed_groups:
  - key: tags.Role
    prefix: role
  - key: tags.Environment
    prefix: env
  - key: placement.availability_zone
    prefix: az

hostnames:
  - tag:Name
  - private-ip-address

compose:
  ansible_host: private_ip_address

Azure Plugin

inventory/azure_rm.yml:

---
plugin: azure.azcollection.azure_rm
include_vm_resource_groups:
  - production-rg

keyed_groups:
  - key: tags.role
    prefix: role
  - key: tags.environment
    prefix: env

conditional_groups:
  webservers: "'web' in tags.role"
  databases: "'db' in tags.role"

Custom Script

inventory/custom.py:

#!/usr/bin/env python3
import json

inventory = {
    "webservers": {
        "hosts": ["web1", "web2"],
        "vars": {
            "nginx_port": 80
        }
    },
    "databases": {
        "hosts": ["db1", "db2"]
    },
    "_meta": {
        "hostvars": {
            "web1": {"ansible_host": "192.168.1.10"},
            "web2": {"ansible_host": "192.168.1.11"},
            "db1": {"ansible_host": "192.168.1.20"},
            "db2": {"ansible_host": "192.168.1.21"}
        }
    }
}

print(json.dumps(inventory))

Inventory Patterns

All hosts:

ansible all -i inventory/production -m ping

Specific group:

ansible webservers -i inventory/production -m ping

Multiple groups:

ansible 'webservers:databases' -i inventory/production -m ping

Exclude group:

ansible 'all:!databases' -i inventory/production -m ping

Intersection:

ansible 'webservers:&production' -i inventory/production -m ping

Regex:

ansible '~web.*' -i inventory/production -m ping

Multi-Environment Setup

inventory/
โ”œโ”€โ”€ production/
โ”‚   โ”œโ”€โ”€ hosts
โ”‚   โ”œโ”€โ”€ group_vars/
โ”‚   โ”‚   โ”œโ”€โ”€ all.yml
โ”‚   โ”‚   โ””โ”€โ”€ webservers.yml
โ”‚   โ””โ”€โ”€ host_vars/
โ”œโ”€โ”€ staging/
โ”‚   โ”œโ”€โ”€ hosts
โ”‚   โ”œโ”€โ”€ group_vars/
โ”‚   โ”‚   โ”œโ”€โ”€ all.yml
โ”‚   โ”‚   โ””โ”€โ”€ webservers.yml
โ”‚   โ””โ”€โ”€ host_vars/
โ””โ”€โ”€ development/
    โ”œโ”€โ”€ hosts
    โ””โ”€โ”€ group_vars/
        โ””โ”€โ”€ all.yml

Usage:

# Production
ansible-playbook -i inventory/production site.yml

# Staging
ansible-playbook -i inventory/staging site.yml

# Development
ansible-playbook -i inventory/development site.yml

Best Practices

  1. Organize inventory by environment
  2. Use group_vars for shared configuration
  3. Use host_vars for host-specific settings
  4. Document inventory structure
  5. Use dynamic inventory for cloud resources
  6. Keep sensitive data in Ansible Vault
  7. Use meaningful group names
  8. Implement proper variable precedence

Score

Total Score

70/100

Based on repository quality metrics

โœ“SKILL.md

SKILL.mdใƒ•ใ‚กใ‚คใƒซใŒๅซใพใ‚Œใฆใ„ใ‚‹

+20
โœ“LICENSE

ใƒฉใ‚คใ‚ปใƒณใ‚นใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+10
โœ“่ชฌๆ˜Žๆ–‡

100ๆ–‡ๅญ—ไปฅไธŠใฎ่ชฌๆ˜ŽใŒใ‚ใ‚‹

+10
โ—‹ไบบๆฐ—

GitHub Stars 100ไปฅไธŠ

0/15
โœ“ๆœ€่ฟ‘ใฎๆดปๅ‹•

1ใƒถๆœˆไปฅๅ†…ใซๆ›ดๆ–ฐ

+10
โ—‹ใƒ•ใ‚ฉใƒผใ‚ฏ

10ๅ›žไปฅไธŠใƒ•ใ‚ฉใƒผใ‚ฏใ•ใ‚Œใฆใ„ใ‚‹

0/5
โœ“Issue็ฎก็†

ใ‚ชใƒผใƒ—ใƒณIssueใŒ50ๆœชๆบ€

+5
โ—‹่จ€่ชž

ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐ่จ€่ชžใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

0/5
โœ“ใ‚ฟใ‚ฐ

1ใคไปฅไธŠใฎใ‚ฟใ‚ฐใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5

Reviews

๐Ÿ’ฌ

Reviews coming soon