refactor(cmdb-assistant): extract skills and slim commands
- Extract 9 skill files from command knowledge: - mcp-tools-reference.md: Complete NetBox MCP tools reference - system-discovery.md: Bash commands for system info gathering - device-registration.md: Device registration workflow - sync-workflow.md: Machine sync process - audit-workflow.md: Data quality audit checks - ip-management.md: IP/prefix management and conflict detection - topology-generation.md: Mermaid diagram generation - change-audit.md: NetBox change audit workflow - visual-header.md: Standard visual header pattern - Slim all 11 commands to under 60 lines: - cmdb-sync.md: 348 -> 57 lines - cmdb-register.md: 334 -> 51 lines - ip-conflicts.md: 238 -> 58 lines - cmdb-audit.md: 207 -> 58 lines - cmdb-topology.md: 194 -> 54 lines - initial-setup.md: 176 -> 74 lines - change-audit.md: 175 -> 57 lines - cmdb-site.md: 68 -> 50 lines - cmdb-ip.md: 65 -> 52 lines - cmdb-device.md: 64 -> 55 lines - cmdb-search.md: 46 lines (unchanged) - Update agent to reference skills for best practices - Preserve existing netbox-patterns skill Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
163
plugins/cmdb-assistant/skills/audit-workflow.md
Normal file
163
plugins/cmdb-assistant/skills/audit-workflow.md
Normal file
@@ -0,0 +1,163 @@
|
||||
# Audit Workflow Skill
|
||||
|
||||
How to audit NetBox data quality.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Load these skills:
|
||||
- `netbox-patterns` - Best practices reference
|
||||
- `mcp-tools-reference` - MCP tool reference
|
||||
|
||||
## Data Collection
|
||||
|
||||
```
|
||||
virt_list_vms
|
||||
dcim_list_devices
|
||||
virt_list_clusters
|
||||
dcim_list_sites
|
||||
tenancy_list_tenants
|
||||
dcim_list_device_roles
|
||||
dcim_list_platforms
|
||||
```
|
||||
|
||||
## Quality Checks by Severity
|
||||
|
||||
### CRITICAL (must fix immediately)
|
||||
|
||||
| Check | Detection |
|
||||
|-------|-----------|
|
||||
| VMs without cluster | `cluster` is null AND `site` is null |
|
||||
| Devices without site | `site` is null |
|
||||
| Active devices without primary IP | `status=active` AND `primary_ip4` is null AND `primary_ip6` is null |
|
||||
|
||||
### HIGH (should fix soon)
|
||||
|
||||
| Check | Detection |
|
||||
|-------|-----------|
|
||||
| VMs without site | No site (neither direct nor via cluster.site) |
|
||||
| VMs without tenant | `tenant` is null |
|
||||
| Devices without platform | `platform` is null |
|
||||
| Clusters not scoped to site | `site` is null on cluster |
|
||||
| VMs without role | `role` is null |
|
||||
|
||||
### MEDIUM (plan to address)
|
||||
|
||||
| Check | Detection |
|
||||
|-------|-----------|
|
||||
| Inconsistent naming | Names don't match patterns |
|
||||
| Role fragmentation | >10 device roles with <3 assignments each |
|
||||
| Missing tags on production | Active resources without tags |
|
||||
| Mixed naming separators | Some `_`, others `-` |
|
||||
|
||||
### LOW (informational)
|
||||
|
||||
| Check | Detection |
|
||||
|-------|-----------|
|
||||
| Docker containers as VMs | Cluster type is "Docker Compose" |
|
||||
| VMs without description | `description` is empty |
|
||||
| Sites without physical address | `physical_address` is empty |
|
||||
| Devices without serial | `serial` is empty |
|
||||
|
||||
## Naming Convention Analysis
|
||||
|
||||
### Expected Patterns
|
||||
|
||||
| Object Type | Pattern | Example |
|
||||
|-------------|---------|---------|
|
||||
| Devices | `{role}-{location}-{number}` | `web-dc1-01` |
|
||||
| VMs | `{env}-{app}-{number}` | `prod-api-01` |
|
||||
| Clusters | `{site}-{type}` | `home-docker` |
|
||||
|
||||
### Analysis Steps
|
||||
|
||||
1. Extract naming patterns from existing objects
|
||||
2. Identify dominant patterns (most common)
|
||||
3. Flag outliers that don't match
|
||||
4. Suggest standardization
|
||||
|
||||
## Role Fragmentation Analysis
|
||||
|
||||
### Red Flags
|
||||
|
||||
- More than 15 highly specific roles
|
||||
- Roles with technology in name (use platform instead)
|
||||
- Roles that duplicate functionality
|
||||
- Single-use roles (only 1 device/VM)
|
||||
|
||||
### Recommended Consolidation
|
||||
|
||||
Use general roles + platform/tags for specificity:
|
||||
- Instead of `nginx-web-server`, use `web-server` + platform `nginx`
|
||||
|
||||
## Report Template
|
||||
|
||||
```markdown
|
||||
## CMDB Data Quality Audit Report
|
||||
|
||||
**Generated:** [timestamp]
|
||||
**Scope:** [scope parameter]
|
||||
|
||||
### Summary
|
||||
|
||||
| Metric | Count |
|
||||
|--------|-------|
|
||||
| Total VMs | X |
|
||||
| Total Devices | Y |
|
||||
| Total Clusters | Z |
|
||||
| **Total Issues** | **N** |
|
||||
|
||||
| Severity | Count |
|
||||
|----------|-------|
|
||||
| Critical | A |
|
||||
| High | B |
|
||||
| Medium | C |
|
||||
| Low | D |
|
||||
|
||||
### Critical Issues
|
||||
|
||||
[List each with specific object names and IDs]
|
||||
|
||||
- VM `HotServ` (ID: 1) - No cluster or site assignment
|
||||
- Device `server-01` (ID: 5) - No site assignment
|
||||
|
||||
### High Issues
|
||||
|
||||
[List each with specific object names]
|
||||
|
||||
### Medium Issues
|
||||
|
||||
[Grouped by category with counts]
|
||||
|
||||
### Recommendations
|
||||
|
||||
1. **[Most impactful fix]** - affects N objects
|
||||
2. **[Second priority]** - affects M objects
|
||||
|
||||
### Quick Fixes
|
||||
|
||||
Commands to fix common issues:
|
||||
|
||||
```
|
||||
# Assign site to VM
|
||||
virt_update_vm id=X site=Y
|
||||
|
||||
# Assign platform to device
|
||||
dcim_update_device id=X platform=Y
|
||||
```
|
||||
|
||||
### Next Steps
|
||||
|
||||
- Run `/cmdb-register` to properly register new machines
|
||||
- Use `/cmdb-sync` to update existing registrations
|
||||
- Consider bulk updates via NetBox web UI for >10 items
|
||||
```
|
||||
|
||||
## Scope-Specific Focus
|
||||
|
||||
| Scope | Focus |
|
||||
|-------|-------|
|
||||
| `all` | Full audit across all categories |
|
||||
| `vms` | Virtual Machine checks only |
|
||||
| `devices` | Device checks only |
|
||||
| `naming` | Naming convention analysis |
|
||||
| `roles` | Role fragmentation analysis |
|
||||
130
plugins/cmdb-assistant/skills/change-audit.md
Normal file
130
plugins/cmdb-assistant/skills/change-audit.md
Normal file
@@ -0,0 +1,130 @@
|
||||
# Change Audit Skill
|
||||
|
||||
Audit NetBox changes for tracking and compliance.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Load skill: `mcp-tools-reference`
|
||||
|
||||
## MCP Tools
|
||||
|
||||
| Tool | Purpose | Parameters |
|
||||
|------|---------|------------|
|
||||
| `extras_list_object_changes` | List changes | `user_id`, `changed_object_type`, `action` |
|
||||
| `extras_get_object_change` | Get change details | `id` |
|
||||
|
||||
## Common Object Types
|
||||
|
||||
| Category | Object Types |
|
||||
|----------|--------------|
|
||||
| DCIM | `dcim.device`, `dcim.interface`, `dcim.site`, `dcim.rack`, `dcim.cable` |
|
||||
| IPAM | `ipam.ipaddress`, `ipam.prefix`, `ipam.vlan`, `ipam.vrf` |
|
||||
| Virtualization | `virtualization.virtualmachine`, `virtualization.cluster` |
|
||||
| Tenancy | `tenancy.tenant`, `tenancy.contact` |
|
||||
|
||||
## Audit Workflow
|
||||
|
||||
1. **Parse user request** - Determine filters
|
||||
2. **Query object changes** - `extras_list_object_changes`
|
||||
3. **Enrich data** - Fetch detailed records if needed
|
||||
4. **Analyze patterns** - Identify bulk operations, unusual activity
|
||||
5. **Generate report** - Structured format
|
||||
|
||||
## Report Template
|
||||
|
||||
```markdown
|
||||
## NetBox Change Audit Report
|
||||
|
||||
**Generated:** [timestamp]
|
||||
**Period:** [date range or "All time"]
|
||||
**Filters:** [applied filters]
|
||||
|
||||
### Summary
|
||||
|
||||
| Metric | Count |
|
||||
|--------|-------|
|
||||
| Total Changes | X |
|
||||
| Creates | Y |
|
||||
| Updates | Z |
|
||||
| Deletes | W |
|
||||
| Unique Users | N |
|
||||
| Object Types | M |
|
||||
|
||||
### Changes by Action
|
||||
|
||||
#### Created Objects (Y)
|
||||
|
||||
| Time | User | Object Type | Object | Details |
|
||||
|------|------|-------------|--------|---------|
|
||||
| 2024-01-15 14:30 | admin | dcim.device | server-01 | Created device |
|
||||
|
||||
#### Updated Objects (Z)
|
||||
|
||||
| Time | User | Object Type | Object | Changed Fields |
|
||||
|------|------|-------------|--------|----------------|
|
||||
| 2024-01-15 15:00 | john | ipam.ipaddress | 10.0.1.50/24 | status, description |
|
||||
|
||||
#### Deleted Objects (W)
|
||||
|
||||
| Time | User | Object Type | Object | Details |
|
||||
|------|------|-------------|--------|---------|
|
||||
| 2024-01-14 09:00 | admin | dcim.interface | eth2 | Removed from server-01 |
|
||||
|
||||
### Changes by User
|
||||
|
||||
| User | Creates | Updates | Deletes | Total |
|
||||
|------|---------|---------|---------|-------|
|
||||
| admin | 5 | 10 | 2 | 17 |
|
||||
| john | 3 | 8 | 0 | 11 |
|
||||
|
||||
### Changes by Object Type
|
||||
|
||||
| Object Type | Creates | Updates | Deletes | Total |
|
||||
|-------------|---------|---------|---------|-------|
|
||||
| dcim.device | 2 | 5 | 0 | 7 |
|
||||
| ipam.ipaddress | 4 | 3 | 1 | 8 |
|
||||
|
||||
### Timeline
|
||||
|
||||
```
|
||||
2024-01-15: ######## 8 changes
|
||||
2024-01-14: #### 4 changes
|
||||
2024-01-13: ## 2 changes
|
||||
```
|
||||
|
||||
### Notable Patterns
|
||||
|
||||
- **Bulk operations:** [Many changes in short time]
|
||||
- **Unusual activity:** [Unexpected deletions, after-hours changes]
|
||||
- **Missing audit trail:** [Expected changes not logged]
|
||||
|
||||
### Recommendations
|
||||
|
||||
1. [Security or process recommendations based on findings]
|
||||
```
|
||||
|
||||
## Enriching Change Details
|
||||
|
||||
For detailed audit, use `extras_get_object_change` to see:
|
||||
- `prechange_data` - Object state before change
|
||||
- `postchange_data` - Object state after change
|
||||
- `request_id` - Links related changes in same request
|
||||
|
||||
## Security Audit Mode
|
||||
|
||||
When user asks for "security audit" or "compliance report":
|
||||
|
||||
1. Focus on deletions and permission-sensitive changes
|
||||
2. Highlight changes to critical objects (firewalls, VRFs, prefixes)
|
||||
3. Flag changes outside business hours
|
||||
4. Identify users with high change counts
|
||||
|
||||
## Filter Examples
|
||||
|
||||
| Request | Filter |
|
||||
|---------|--------|
|
||||
| Recent changes | None (last 24 hours default) |
|
||||
| Last 7 days | Filter by `time` field |
|
||||
| By user | `user_id=<id>` |
|
||||
| Device changes | `changed_object_type=dcim.device` |
|
||||
| All deletions | `action=delete` |
|
||||
177
plugins/cmdb-assistant/skills/device-registration.md
Normal file
177
plugins/cmdb-assistant/skills/device-registration.md
Normal file
@@ -0,0 +1,177 @@
|
||||
# Device Registration Skill
|
||||
|
||||
How to register devices into NetBox.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Load these skills:
|
||||
- `system-discovery` - Bash commands for gathering system info
|
||||
- `netbox-patterns` - Best practices for data quality
|
||||
- `mcp-tools-reference` - MCP tool reference
|
||||
|
||||
## Registration Workflow
|
||||
|
||||
### Phase 1: System Discovery
|
||||
|
||||
Use commands from `system-discovery` skill to gather:
|
||||
- Hostname, OS, hardware model, serial number
|
||||
- CPU, memory, disk
|
||||
- Network interfaces with IPs
|
||||
- Running Docker containers
|
||||
|
||||
### Phase 2: Pre-Registration Checks
|
||||
|
||||
1. **Check if device exists:**
|
||||
```
|
||||
dcim_list_devices name=<hostname>
|
||||
```
|
||||
If exists, suggest `/cmdb-sync` instead.
|
||||
|
||||
2. **Verify/Create site:**
|
||||
```
|
||||
dcim_list_sites name=<site-name>
|
||||
```
|
||||
If not found, list available sites or offer to create.
|
||||
|
||||
3. **Verify/Create platform:**
|
||||
```
|
||||
dcim_list_platforms name=<platform-name>
|
||||
```
|
||||
Create if not exists with `dcim_create_platform`.
|
||||
|
||||
4. **Verify/Create device role:**
|
||||
```
|
||||
dcim_list_device_roles name=<role-name>
|
||||
```
|
||||
|
||||
### Phase 3: Device Creation
|
||||
|
||||
1. **Get/Create manufacturer and device type:**
|
||||
```
|
||||
dcim_list_manufacturers name="<manufacturer>"
|
||||
dcim_list_device_types manufacturer_id=X model="<model>"
|
||||
```
|
||||
|
||||
2. **Create device:**
|
||||
```
|
||||
dcim_create_device
|
||||
name=<hostname>
|
||||
device_type=<device_type_id>
|
||||
role=<role_id>
|
||||
site=<site_id>
|
||||
platform=<platform_id>
|
||||
tenant=<tenant_id> # if provided
|
||||
serial=<serial>
|
||||
description="Registered via cmdb-assistant"
|
||||
```
|
||||
|
||||
3. **Create interfaces:**
|
||||
For each network interface:
|
||||
```
|
||||
dcim_create_interface
|
||||
device=<device_id>
|
||||
name=<interface_name>
|
||||
type=<type>
|
||||
mac_address=<mac>
|
||||
enabled=true
|
||||
```
|
||||
|
||||
4. **Create IP addresses:**
|
||||
For each IP:
|
||||
```
|
||||
ipam_create_ip_address
|
||||
address=<ip/prefix>
|
||||
assigned_object_type="dcim.interface"
|
||||
assigned_object_id=<interface_id>
|
||||
status="active"
|
||||
```
|
||||
|
||||
5. **Set primary IP:**
|
||||
```
|
||||
dcim_update_device
|
||||
id=<device_id>
|
||||
primary_ip4=<primary_ip_id>
|
||||
```
|
||||
|
||||
### Phase 4: Container Registration (if Docker)
|
||||
|
||||
1. **Create/Get cluster type:**
|
||||
```
|
||||
virt_list_cluster_types name="Docker Compose"
|
||||
virt_create_cluster_type name="Docker Compose" slug="docker-compose"
|
||||
```
|
||||
|
||||
2. **Create cluster:**
|
||||
```
|
||||
virt_create_cluster
|
||||
name=<project-name>
|
||||
type=<cluster_type_id>
|
||||
site=<site_id>
|
||||
description="Docker Compose stack on <hostname>"
|
||||
```
|
||||
|
||||
3. **Create VMs for containers:**
|
||||
For each running container:
|
||||
```
|
||||
virt_create_vm
|
||||
name=<container_name>
|
||||
cluster=<cluster_id>
|
||||
site=<site_id>
|
||||
role=<role_id>
|
||||
status="active"
|
||||
vcpus=<cpu_shares>
|
||||
memory=<memory_mb>
|
||||
disk=<disk_gb>
|
||||
```
|
||||
|
||||
### Phase 5: Documentation
|
||||
|
||||
Add journal entry:
|
||||
```
|
||||
extras_create_journal_entry
|
||||
assigned_object_type="dcim.device"
|
||||
assigned_object_id=<device_id>
|
||||
comments="Device registered via /cmdb-register command\n\nDiscovered:\n- X network interfaces\n- Y IP addresses\n- Z Docker containers"
|
||||
```
|
||||
|
||||
## Summary Report Template
|
||||
|
||||
```markdown
|
||||
## Machine Registration Complete
|
||||
|
||||
### Device Created
|
||||
- **Name:** <hostname>
|
||||
- **Site:** <site>
|
||||
- **Platform:** <platform>
|
||||
- **Role:** <role>
|
||||
- **ID:** <device_id>
|
||||
- **URL:** https://netbox.example.com/dcim/devices/<id>/
|
||||
|
||||
### Network Interfaces
|
||||
| Interface | Type | MAC | IP Address |
|
||||
|-----------|------|-----|------------|
|
||||
| eth0 | 1000base-t | aa:bb:cc:dd:ee:ff | 192.168.1.100/24 |
|
||||
|
||||
### Primary IP: 192.168.1.100
|
||||
|
||||
### Docker Containers Registered (if applicable)
|
||||
**Cluster:** <cluster_name> (ID: <cluster_id>)
|
||||
|
||||
| Container | Role | vCPUs | Memory | Status |
|
||||
|-----------|------|-------|--------|--------|
|
||||
| media_jellyfin | Media Server | 2.0 | 2048MB | Active |
|
||||
|
||||
### Next Steps
|
||||
- Run `/cmdb-sync` periodically to keep data current
|
||||
- Run `/cmdb-audit` to check data quality
|
||||
- Add tags for classification
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Action |
|
||||
|-------|--------|
|
||||
| Device already exists | Suggest `/cmdb-sync` or ask to proceed |
|
||||
| Site not found | List available sites, offer to create new |
|
||||
| Docker not available | Skip container registration, note in summary |
|
||||
| Permission denied | Note which operations failed, suggest fixes |
|
||||
162
plugins/cmdb-assistant/skills/ip-management.md
Normal file
162
plugins/cmdb-assistant/skills/ip-management.md
Normal file
@@ -0,0 +1,162 @@
|
||||
# IP Management Skill
|
||||
|
||||
IP address and prefix management in NetBox.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Load skill: `mcp-tools-reference`
|
||||
|
||||
## IPAM Operations
|
||||
|
||||
### Prefix Management
|
||||
|
||||
| Action | Tool | Key Parameters |
|
||||
|--------|------|----------------|
|
||||
| List prefixes | `ipam_list_prefixes` | `prefix`, `vrf_id`, `within`, `contains` |
|
||||
| Get details | `ipam_get_prefix` | `id` |
|
||||
| Find available child | `ipam_list_available_prefixes` | `prefix_id` |
|
||||
| Create prefix | `ipam_create_prefix` | `prefix`, `status`, `site`, `vrf` |
|
||||
| Allocate child | `ipam_create_available_prefix` | `prefix_id`, `prefix_length` |
|
||||
|
||||
### IP Address Management
|
||||
|
||||
| Action | Tool | Key Parameters |
|
||||
|--------|------|----------------|
|
||||
| List IPs | `ipam_list_ip_addresses` | `address`, `vrf_id`, `device_id` |
|
||||
| Get details | `ipam_get_ip_address` | `id` |
|
||||
| Find available | `ipam_list_available_ips` | `prefix_id` |
|
||||
| Create IP | `ipam_create_ip_address` | `address`, `assigned_object_type`, `assigned_object_id` |
|
||||
| Allocate next | `ipam_create_available_ip` | `prefix_id` |
|
||||
| Assign to interface | `ipam_update_ip_address` | `id`, `assigned_object_id` |
|
||||
|
||||
### VLAN and VRF
|
||||
|
||||
| Action | Tool |
|
||||
|--------|------|
|
||||
| List VLANs | `ipam_list_vlans` |
|
||||
| Get VLAN | `ipam_get_vlan` |
|
||||
| Create VLAN | `ipam_create_vlan` |
|
||||
| List VRFs | `ipam_list_vrfs` |
|
||||
| Get VRF | `ipam_get_vrf` |
|
||||
|
||||
## IP Allocation Workflow
|
||||
|
||||
1. **Find available IPs in target prefix:**
|
||||
```
|
||||
ipam_list_available_ips prefix_id=<id>
|
||||
```
|
||||
|
||||
2. **Create the IP address:**
|
||||
```
|
||||
ipam_create_ip_address
|
||||
address=<ip/prefix>
|
||||
assigned_object_type="dcim.interface"
|
||||
assigned_object_id=<interface_id>
|
||||
status="active"
|
||||
```
|
||||
|
||||
3. **Set as primary (if needed):**
|
||||
```
|
||||
dcim_update_device id=<device_id> primary_ip4=<ip_id>
|
||||
```
|
||||
|
||||
## IP Conflict Detection
|
||||
|
||||
### Conflict Types
|
||||
|
||||
1. **Duplicate IP Addresses**
|
||||
- Multiple records with same address in same VRF
|
||||
- Exception: Anycast addresses (check `role` field)
|
||||
|
||||
2. **Overlapping Prefixes**
|
||||
- Prefixes containing same address space in same VRF
|
||||
- Legitimate: Parent/child hierarchy, different VRFs, "container" status
|
||||
|
||||
3. **IPs Outside Prefix**
|
||||
- IP addresses not within any defined prefix
|
||||
|
||||
4. **Same Prefix in Multiple VRFs** (informational)
|
||||
|
||||
### Detection Workflow
|
||||
|
||||
1. **Duplicate Detection:**
|
||||
- Get all addresses: `ipam_list_ip_addresses`
|
||||
- Group by address + VRF
|
||||
- Flag groups with >1 record
|
||||
|
||||
2. **Overlap Detection:**
|
||||
- Get all prefixes: `ipam_list_prefixes`
|
||||
- For each VRF, compare prefixes pairwise
|
||||
- Check if prefix A contains prefix B or vice versa
|
||||
- Ignore legitimate hierarchies (status=container)
|
||||
|
||||
3. **Orphan IP Detection:**
|
||||
- For each IP, find containing prefix
|
||||
- Flag IPs with no prefix match
|
||||
|
||||
### CIDR Math Rules
|
||||
|
||||
- Prefix A **contains** Prefix B if: `A.network <= B.network AND A.broadcast >= B.broadcast`
|
||||
- Two prefixes **overlap** if: `A.network <= B.broadcast AND B.network <= A.broadcast`
|
||||
|
||||
### Severity Levels
|
||||
|
||||
| Issue | Severity |
|
||||
|-------|----------|
|
||||
| Duplicate IP (same interface type) | CRITICAL |
|
||||
| Duplicate IP (different roles) | HIGH |
|
||||
| Overlapping prefixes (same status) | HIGH |
|
||||
| Overlapping prefixes (container ok) | LOW |
|
||||
| Orphan IP | MEDIUM |
|
||||
|
||||
## Conflict Report Template
|
||||
|
||||
```markdown
|
||||
## IP Conflict Detection Report
|
||||
|
||||
**Generated:** [timestamp]
|
||||
**Scope:** [scope parameter]
|
||||
|
||||
### Summary
|
||||
|
||||
| Check | Status | Count |
|
||||
|-------|--------|-------|
|
||||
| Duplicate IPs | [PASS/FAIL] | X |
|
||||
| Overlapping Prefixes | [PASS/FAIL] | Y |
|
||||
| Orphan IPs | [PASS/FAIL] | Z |
|
||||
|
||||
### Critical Issues
|
||||
|
||||
#### Duplicate IP Addresses
|
||||
|
||||
| Address | VRF | Count | Assigned To |
|
||||
|---------|-----|-------|-------------|
|
||||
| 10.0.1.50/24 | Global | 2 | server-01, server-02 |
|
||||
|
||||
**Resolution:**
|
||||
- Determine which device should have the IP
|
||||
- Update or remove the duplicate
|
||||
|
||||
#### Overlapping Prefixes
|
||||
|
||||
| Prefix 1 | Prefix 2 | VRF | Type |
|
||||
|----------|----------|-----|------|
|
||||
| 10.0.0.0/24 | 10.0.0.0/25 | Global | Unstructured |
|
||||
|
||||
**Resolution:**
|
||||
- For legitimate hierarchies: Mark parent as status="container"
|
||||
- For accidental: Consolidate or re-address
|
||||
|
||||
### Remediation Commands
|
||||
|
||||
```
|
||||
# Remove duplicate IP
|
||||
ipam_delete_ip_address id=123
|
||||
|
||||
# Mark prefix as container
|
||||
ipam_update_prefix id=456 status=container
|
||||
|
||||
# Create missing prefix
|
||||
ipam_create_prefix prefix=172.16.5.0/24 status=active
|
||||
```
|
||||
```
|
||||
281
plugins/cmdb-assistant/skills/mcp-tools-reference.md
Normal file
281
plugins/cmdb-assistant/skills/mcp-tools-reference.md
Normal file
@@ -0,0 +1,281 @@
|
||||
# NetBox MCP Tools Reference
|
||||
|
||||
Complete reference for NetBox MCP tools organized by category.
|
||||
|
||||
## DCIM (Data Center Infrastructure Management)
|
||||
|
||||
### Sites and Locations
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `dcim_list_sites` | List all sites | `name`, `status`, `region_id` |
|
||||
| `dcim_get_site` | Get site details | `id` |
|
||||
| `dcim_create_site` | Create new site | `name`, `slug`, `status` |
|
||||
| `dcim_update_site` | Update site | `id`, fields to update |
|
||||
| `dcim_delete_site` | Delete site | `id` |
|
||||
| `dcim_list_locations` | List locations within sites | `site_id`, `parent_id` |
|
||||
| `dcim_get_location` | Get location details | `id` |
|
||||
| `dcim_create_location` | Create location | `name`, `slug`, `site` |
|
||||
| `dcim_update_location` | Update location | `id`, fields to update |
|
||||
| `dcim_delete_location` | Delete location | `id` |
|
||||
| `dcim_list_regions` | List regions | `name` |
|
||||
| `dcim_get_region` | Get region details | `id` |
|
||||
| `dcim_create_region` | Create region | `name`, `slug` |
|
||||
| `dcim_update_region` | Update region | `id`, fields to update |
|
||||
| `dcim_delete_region` | Delete region | `id` |
|
||||
|
||||
### Racks
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `dcim_list_racks` | List racks | `site_id`, `location_id`, `name` |
|
||||
| `dcim_get_rack` | Get rack details | `id` |
|
||||
| `dcim_create_rack` | Create rack | `name`, `site`, `u_height` |
|
||||
| `dcim_update_rack` | Update rack | `id`, fields to update |
|
||||
| `dcim_delete_rack` | Delete rack | `id` |
|
||||
|
||||
### Devices
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `dcim_list_devices` | List devices | `name`, `site_id`, `role_id`, `status` |
|
||||
| `dcim_get_device` | Get device details | `id` |
|
||||
| `dcim_create_device` | Create device | `name`, `device_type`, `role`, `site` |
|
||||
| `dcim_update_device` | Update device | `id`, `primary_ip4`, etc. |
|
||||
| `dcim_delete_device` | Delete device | `id` |
|
||||
|
||||
### Device Types and Roles
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `dcim_list_device_types` | List device types | `manufacturer_id`, `model` |
|
||||
| `dcim_get_device_type` | Get type details | `id` |
|
||||
| `dcim_create_device_type` | Create device type | `manufacturer`, `model`, `slug` |
|
||||
| `dcim_update_device_type` | Update device type | `id`, fields |
|
||||
| `dcim_delete_device_type` | Delete device type | `id` |
|
||||
| `dcim_list_device_roles` | List device roles | `name` |
|
||||
| `dcim_get_device_role` | Get role details | `id` |
|
||||
| `dcim_create_device_role` | Create device role | `name`, `slug` |
|
||||
| `dcim_update_device_role` | Update device role | `id`, fields |
|
||||
| `dcim_delete_device_role` | Delete device role | `id` |
|
||||
|
||||
### Manufacturers and Platforms
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `dcim_list_manufacturers` | List manufacturers | `name` |
|
||||
| `dcim_get_manufacturer` | Get manufacturer details | `id` |
|
||||
| `dcim_create_manufacturer` | Create manufacturer | `name`, `slug` |
|
||||
| `dcim_update_manufacturer` | Update manufacturer | `id`, fields |
|
||||
| `dcim_delete_manufacturer` | Delete manufacturer | `id` |
|
||||
| `dcim_list_platforms` | List platforms | `name` |
|
||||
| `dcim_get_platform` | Get platform details | `id` |
|
||||
| `dcim_create_platform` | Create platform | `name`, `slug` |
|
||||
| `dcim_update_platform` | Update platform | `id`, fields |
|
||||
| `dcim_delete_platform` | Delete platform | `id` |
|
||||
|
||||
### Interfaces and Cables
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `dcim_list_interfaces` | List interfaces | `device_id`, `name`, `type` |
|
||||
| `dcim_get_interface` | Get interface details | `id` |
|
||||
| `dcim_create_interface` | Create interface | `device`, `name`, `type` |
|
||||
| `dcim_update_interface` | Update interface | `id`, `enabled`, `mac_address` |
|
||||
| `dcim_delete_interface` | Delete interface | `id` |
|
||||
| `dcim_list_cables` | List cables | `device_id`, `site_id` |
|
||||
| `dcim_get_cable` | Get cable details | `id` |
|
||||
| `dcim_create_cable` | Create cable | `a_terminations`, `b_terminations` |
|
||||
| `dcim_update_cable` | Update cable | `id`, fields |
|
||||
| `dcim_delete_cable` | Delete cable | `id` |
|
||||
|
||||
### Power
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `dcim_list_power_panels` | List power panels | `site_id` |
|
||||
| `dcim_get_power_panel` | Get panel details | `id` |
|
||||
| `dcim_create_power_panel` | Create power panel | `name`, `site` |
|
||||
| `dcim_list_power_feeds` | List power feeds | `power_panel_id` |
|
||||
| `dcim_get_power_feed` | Get feed details | `id` |
|
||||
| `dcim_create_power_feed` | Create power feed | `name`, `power_panel`, `supply` |
|
||||
|
||||
### Other DCIM
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `dcim_list_virtual_chassis` | List virtual chassis | (varies) |
|
||||
| `dcim_get_virtual_chassis` | Get virtual chassis | `id` |
|
||||
| `dcim_list_inventory_items` | List inventory items | `device_id` |
|
||||
| `dcim_get_inventory_item` | Get inventory item | `id` |
|
||||
|
||||
## IPAM (IP Address Management)
|
||||
|
||||
### Prefixes
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `ipam_list_prefixes` | List prefixes | `prefix`, `vrf_id`, `within`, `contains` |
|
||||
| `ipam_get_prefix` | Get prefix details | `id` |
|
||||
| `ipam_create_prefix` | Create prefix | `prefix`, `status`, `site`, `vrf` |
|
||||
| `ipam_update_prefix` | Update prefix | `id`, `status`, etc. |
|
||||
| `ipam_delete_prefix` | Delete prefix | `id` |
|
||||
| `ipam_list_available_prefixes` | List available child prefixes | `prefix_id` |
|
||||
| `ipam_create_available_prefix` | Allocate from parent | `prefix_id`, `prefix_length` |
|
||||
|
||||
### IP Addresses
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `ipam_list_ip_addresses` | List IP addresses | `address`, `vrf_id`, `device_id`, `status` |
|
||||
| `ipam_get_ip_address` | Get IP details | `id` |
|
||||
| `ipam_create_ip_address` | Create IP address | `address`, `assigned_object_type`, `assigned_object_id` |
|
||||
| `ipam_update_ip_address` | Update IP address | `id`, `status`, etc. |
|
||||
| `ipam_delete_ip_address` | Delete IP address | `id` |
|
||||
| `ipam_list_available_ips` | List available IPs in prefix | `prefix_id` |
|
||||
| `ipam_create_available_ip` | Allocate next available | `prefix_id` |
|
||||
|
||||
### VLANs and VRFs
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `ipam_list_vlans` | List VLANs | `vid`, `name`, `site_id` |
|
||||
| `ipam_get_vlan` | Get VLAN details | `id` |
|
||||
| `ipam_create_vlan` | Create VLAN | `vid`, `name`, `site` |
|
||||
| `ipam_update_vlan` | Update VLAN | `id`, fields |
|
||||
| `ipam_delete_vlan` | Delete VLAN | `id` |
|
||||
| `ipam_list_vlan_groups` | List VLAN groups | `site_id` |
|
||||
| `ipam_get_vlan_group` | Get VLAN group | `id` |
|
||||
| `ipam_create_vlan_group` | Create VLAN group | `name`, `slug`, `scope_type` |
|
||||
| `ipam_list_vrfs` | List VRFs | `name` |
|
||||
| `ipam_get_vrf` | Get VRF details | `id` |
|
||||
| `ipam_create_vrf` | Create VRF | `name`, `rd` |
|
||||
| `ipam_update_vrf` | Update VRF | `id`, fields |
|
||||
| `ipam_delete_vrf` | Delete VRF | `id` |
|
||||
|
||||
### Other IPAM
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `ipam_list_asns` | List ASNs | (varies) |
|
||||
| `ipam_get_asn` | Get ASN details | `id` |
|
||||
| `ipam_create_asn` | Create ASN | `asn`, `rir` |
|
||||
| `ipam_list_rirs` | List RIRs | `name` |
|
||||
| `ipam_get_rir` | Get RIR details | `id` |
|
||||
| `ipam_list_aggregates` | List aggregates | `prefix`, `rir_id` |
|
||||
| `ipam_get_aggregate` | Get aggregate | `id` |
|
||||
| `ipam_create_aggregate` | Create aggregate | `prefix`, `rir` |
|
||||
| `ipam_list_services` | List services | `device_id`, `name` |
|
||||
| `ipam_get_service` | Get service details | `id` |
|
||||
| `ipam_create_service` | Create service | `name`, `ports`, `protocol` |
|
||||
|
||||
## Virtualization
|
||||
|
||||
### Clusters
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `virt_list_cluster_types` | List cluster types | `name` |
|
||||
| `virt_get_cluster_type` | Get cluster type | `id` |
|
||||
| `virt_create_cluster_type` | Create cluster type | `name`, `slug` |
|
||||
| `virt_list_cluster_groups` | List cluster groups | `name` |
|
||||
| `virt_get_cluster_group` | Get cluster group | `id` |
|
||||
| `virt_create_cluster_group` | Create cluster group | `name`, `slug` |
|
||||
| `virt_list_clusters` | List clusters | `name`, `site_id`, `type_id` |
|
||||
| `virt_get_cluster` | Get cluster details | `id` |
|
||||
| `virt_create_cluster` | Create cluster | `name`, `type`, `site` |
|
||||
| `virt_update_cluster` | Update cluster | `id`, fields |
|
||||
| `virt_delete_cluster` | Delete cluster | `id` |
|
||||
|
||||
### Virtual Machines
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `virt_list_vms` | List VMs | `name`, `cluster_id`, `site_id`, `status` |
|
||||
| `virt_get_vm` | Get VM details | `id` |
|
||||
| `virt_create_vm` | Create VM | `name`, `cluster`, `site`, `status` |
|
||||
| `virt_update_vm` | Update VM | `id`, `status`, etc. |
|
||||
| `virt_delete_vm` | Delete VM | `id` |
|
||||
| `virt_list_vm_ifaces` | List VM interfaces | `virtual_machine_id` |
|
||||
| `virt_get_vm_iface` | Get VM interface | `id` |
|
||||
| `virt_create_vm_iface` | Create VM interface | `virtual_machine`, `name` |
|
||||
|
||||
## Circuits
|
||||
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `circuits_list_providers` | List providers | `name` |
|
||||
| `circuits_get_provider` | Get provider | `id` |
|
||||
| `circuits_create_provider` | Create provider | `name`, `slug` |
|
||||
| `circuits_update_provider` | Update provider | `id`, fields |
|
||||
| `circuits_delete_provider` | Delete provider | `id` |
|
||||
| `circ_list_types` | List circuit types | `name` |
|
||||
| `circ_get_type` | Get circuit type | `id` |
|
||||
| `circ_create_type` | Create circuit type | `name`, `slug` |
|
||||
| `circuits_list_circuits` | List circuits | `provider_id`, `type_id` |
|
||||
| `circuits_get_circuit` | Get circuit | `id` |
|
||||
| `circuits_create_circuit` | Create circuit | `cid`, `provider`, `type` |
|
||||
| `circuits_update_circuit` | Update circuit | `id`, fields |
|
||||
| `circuits_delete_circuit` | Delete circuit | `id` |
|
||||
| `circ_list_terminations` | List terminations | `circuit_id` |
|
||||
| `circ_get_termination` | Get termination | `id` |
|
||||
| `circ_create_termination` | Create termination | `circuit`, `site`, `term_side` |
|
||||
|
||||
## Tenancy
|
||||
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `tenancy_list_tenant_groups` | List tenant groups | `name` |
|
||||
| `tenancy_get_tenant_group` | Get tenant group | `id` |
|
||||
| `tenancy_create_tenant_group` | Create tenant group | `name`, `slug` |
|
||||
| `tenancy_list_tenants` | List tenants | `name`, `group_id` |
|
||||
| `tenancy_get_tenant` | Get tenant | `id` |
|
||||
| `tenancy_create_tenant` | Create tenant | `name`, `slug` |
|
||||
| `tenancy_update_tenant` | Update tenant | `id`, fields |
|
||||
| `tenancy_delete_tenant` | Delete tenant | `id` |
|
||||
| `tenancy_list_contacts` | List contacts | `name` |
|
||||
| `tenancy_get_contact` | Get contact | `id` |
|
||||
| `tenancy_create_contact` | Create contact | `name` |
|
||||
|
||||
## VPN
|
||||
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `vpn_list_tunnels` | List VPN tunnels | `name` |
|
||||
| `vpn_get_tunnel` | Get tunnel | `id` |
|
||||
| `vpn_create_tunnel` | Create tunnel | `name`, `status` |
|
||||
| `vpn_list_l2vpns` | List L2VPNs | `name` |
|
||||
| `vpn_get_l2vpn` | Get L2VPN | `id` |
|
||||
| `vpn_create_l2vpn` | Create L2VPN | `name`, `type` |
|
||||
| `vpn_list_ike_policies` | List IKE policies | (varies) |
|
||||
| `vpn_list_ipsec_policies` | List IPSec policies | (varies) |
|
||||
| `vpn_list_ipsec_profiles` | List IPSec profiles | (varies) |
|
||||
|
||||
## Wireless
|
||||
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `wlan_list_groups` | List WLAN groups | `name` |
|
||||
| `wlan_get_group` | Get WLAN group | `id` |
|
||||
| `wlan_create_group` | Create WLAN group | `name`, `slug` |
|
||||
| `wlan_list_lans` | List WLANs | `ssid` |
|
||||
| `wlan_get_lan` | Get WLAN | `id` |
|
||||
| `wlan_create_lan` | Create WLAN | `ssid`, `group` |
|
||||
| `wlan_list_links` | List wireless links | (varies) |
|
||||
| `wlan_get_link` | Get wireless link | `id` |
|
||||
|
||||
## Extras
|
||||
|
||||
| Tool | Purpose | Key Parameters |
|
||||
|------|---------|----------------|
|
||||
| `extras_list_tags` | List tags | `name` |
|
||||
| `extras_get_tag` | Get tag | `id` |
|
||||
| `extras_create_tag` | Create tag | `name`, `slug`, `color` |
|
||||
| `extras_update_tag` | Update tag | `id`, fields |
|
||||
| `extras_delete_tag` | Delete tag | `id` |
|
||||
| `extras_list_custom_fields` | List custom fields | `name` |
|
||||
| `extras_get_custom_field` | Get custom field | `id` |
|
||||
| `extras_list_webhooks` | List webhooks | `name` |
|
||||
| `extras_get_webhook` | Get webhook | `id` |
|
||||
| `extras_list_journal_entries` | List journal entries | `assigned_object_type`, `assigned_object_id` |
|
||||
| `extras_get_journal_entry` | Get journal entry | `id` |
|
||||
| `extras_create_journal_entry` | Create journal entry | `assigned_object_type`, `assigned_object_id`, `comments` |
|
||||
| `extras_list_object_changes` | List audit log | `user_id`, `changed_object_type`, `action` |
|
||||
| `extras_get_object_change` | Get change details | `id` |
|
||||
| `extras_list_config_contexts` | List config contexts | `name` |
|
||||
| `extras_get_config_context` | Get config context | `id` |
|
||||
|
||||
## Common Object Types for Filtering
|
||||
|
||||
| Category | Object Types |
|
||||
|----------|--------------|
|
||||
| DCIM | `dcim.device`, `dcim.interface`, `dcim.site`, `dcim.rack`, `dcim.cable` |
|
||||
| IPAM | `ipam.ipaddress`, `ipam.prefix`, `ipam.vlan`, `ipam.vrf` |
|
||||
| Virtualization | `virtualization.virtualmachine`, `virtualization.cluster` |
|
||||
| Tenancy | `tenancy.tenant`, `tenancy.contact` |
|
||||
191
plugins/cmdb-assistant/skills/sync-workflow.md
Normal file
191
plugins/cmdb-assistant/skills/sync-workflow.md
Normal file
@@ -0,0 +1,191 @@
|
||||
# Sync Workflow Skill
|
||||
|
||||
How to synchronize machine state with NetBox.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Load these skills:
|
||||
- `system-discovery` - Bash commands for system info
|
||||
- `mcp-tools-reference` - MCP tool reference
|
||||
|
||||
## Sync Workflow
|
||||
|
||||
### Phase 1: Device Lookup
|
||||
|
||||
```
|
||||
dcim_list_devices name=<hostname>
|
||||
```
|
||||
|
||||
If not found, suggest `/cmdb-register` first.
|
||||
|
||||
If found:
|
||||
- Store device ID and current field values
|
||||
- Fetch interfaces: `dcim_list_interfaces device_id=<device_id>`
|
||||
- Fetch IPs: `ipam_list_ip_addresses device_id=<device_id>`
|
||||
- Check clusters/VMs: `virt_list_clusters`, `virt_list_vms cluster=<cluster_id>`
|
||||
|
||||
### Phase 2: Current State Discovery
|
||||
|
||||
Use commands from `system-discovery` skill.
|
||||
|
||||
### Phase 3: Comparison
|
||||
|
||||
#### Device Attributes
|
||||
| Field | Compare |
|
||||
|-------|---------|
|
||||
| Platform | OS version changed? |
|
||||
| Status | Still active? |
|
||||
| Serial | Match? |
|
||||
| Description | Keep existing |
|
||||
|
||||
#### Network Interfaces
|
||||
| Change Type | Detection |
|
||||
|-------------|-----------|
|
||||
| New interface | Exists locally but not in NetBox |
|
||||
| Removed interface | In NetBox but not locally |
|
||||
| Changed MAC | MAC address different |
|
||||
| Interface type | Type mismatch |
|
||||
|
||||
#### IP Addresses
|
||||
| Change Type | Detection |
|
||||
|-------------|-----------|
|
||||
| New IP | Exists locally but not in NetBox |
|
||||
| Removed IP | In NetBox but not locally |
|
||||
| Primary IP changed | Default route interface changed |
|
||||
|
||||
#### Docker Containers
|
||||
| Change Type | Detection |
|
||||
|-------------|-----------|
|
||||
| New container | Running locally but no VM in cluster |
|
||||
| Stopped container | VM exists but container not running |
|
||||
| Resource change | vCPUs/memory different |
|
||||
|
||||
### Phase 4: Diff Report
|
||||
|
||||
```markdown
|
||||
## Sync Diff Report
|
||||
|
||||
**Device:** <hostname> (ID: <device_id>)
|
||||
**NetBox URL:** https://netbox.example.com/dcim/devices/<id>/
|
||||
|
||||
### Device Attributes
|
||||
| Field | NetBox Value | Current Value | Action |
|
||||
|-------|--------------|---------------|--------|
|
||||
| Platform | Ubuntu 22.04 | Ubuntu 24.04 | UPDATE |
|
||||
|
||||
### Network Interfaces
|
||||
|
||||
#### New Interfaces (will create)
|
||||
| Interface | Type | MAC | IPs |
|
||||
|-----------|------|-----|-----|
|
||||
| tailscale0 | virtual | - | 100.x.x.x/32 |
|
||||
|
||||
#### Removed Interfaces (will mark offline)
|
||||
| Interface | Type | Reason |
|
||||
|-----------|------|--------|
|
||||
| eth1 | 1000base-t | Not found locally |
|
||||
|
||||
#### Changed Interfaces
|
||||
| Interface | Field | Old | New |
|
||||
|-----------|-------|-----|-----|
|
||||
| eth0 | mac_address | aa:bb:cc:00:00:00 | aa:bb:cc:11:11:11 |
|
||||
|
||||
### IP Addresses
|
||||
|
||||
#### New IPs (will create)
|
||||
- 192.168.1.150/24 on eth0
|
||||
|
||||
#### Removed IPs (will unassign)
|
||||
- 192.168.1.100/24 from eth0
|
||||
|
||||
### Docker Containers
|
||||
|
||||
#### New Containers (will create VMs)
|
||||
| Container | Image | Role |
|
||||
|-----------|-------|------|
|
||||
| media_lidarr | linuxserver/lidarr | Media Management |
|
||||
|
||||
### Summary
|
||||
- **Updates:** X
|
||||
- **Creates:** Y
|
||||
- **Removals/Offline:** Z
|
||||
```
|
||||
|
||||
### Phase 5: Apply Updates
|
||||
|
||||
#### Device Updates
|
||||
```
|
||||
dcim_update_device id=<device_id> platform=<new_platform_id>
|
||||
```
|
||||
|
||||
#### Interface Updates
|
||||
New:
|
||||
```
|
||||
dcim_create_interface device=<device_id> name=<name> type=<type>
|
||||
```
|
||||
|
||||
Removed (mark offline):
|
||||
```
|
||||
dcim_update_interface id=<id> enabled=false description="Marked offline by cmdb-sync"
|
||||
```
|
||||
|
||||
Changed:
|
||||
```
|
||||
dcim_update_interface id=<id> mac_address=<new_mac>
|
||||
```
|
||||
|
||||
#### IP Address Updates
|
||||
New:
|
||||
```
|
||||
ipam_create_ip_address address=<ip/prefix> assigned_object_type="dcim.interface" assigned_object_id=<id>
|
||||
```
|
||||
|
||||
Removed (unassign):
|
||||
```
|
||||
ipam_update_ip_address id=<id> assigned_object_type=null assigned_object_id=null
|
||||
```
|
||||
|
||||
#### Primary IP Update
|
||||
```
|
||||
dcim_update_device id=<device_id> primary_ip4=<new_primary_ip_id>
|
||||
```
|
||||
|
||||
#### Container/VM Updates
|
||||
New:
|
||||
```
|
||||
virt_create_vm name=<name> cluster=<cluster_id> status="active"
|
||||
```
|
||||
|
||||
Stopped:
|
||||
```
|
||||
virt_update_vm id=<id> status="offline"
|
||||
```
|
||||
|
||||
### Phase 6: Journal Entry
|
||||
|
||||
```
|
||||
extras_create_journal_entry
|
||||
assigned_object_type="dcim.device"
|
||||
assigned_object_id=<device_id>
|
||||
comments="Device synced via /cmdb-sync command\n\nChanges applied:\n- <list>"
|
||||
```
|
||||
|
||||
## Sync Modes
|
||||
|
||||
### Dry Run Mode
|
||||
- Complete phases 1-4 (lookup, discovery, compare, diff report)
|
||||
- Skip phases 5-6 (no updates, no journal)
|
||||
- End with: "Dry run complete. No changes applied."
|
||||
|
||||
### Full Sync Mode
|
||||
- Skip user confirmation
|
||||
- Update all fields even if unchanged (force refresh)
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Action |
|
||||
|-------|--------|
|
||||
| Device not found | Suggest `/cmdb-register` |
|
||||
| Permission denied | Note which failed, continue others |
|
||||
| Cluster not found | Offer to create or skip container sync |
|
||||
| API errors | Log error, continue with remaining |
|
||||
101
plugins/cmdb-assistant/skills/system-discovery.md
Normal file
101
plugins/cmdb-assistant/skills/system-discovery.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# System Discovery Skill
|
||||
|
||||
Bash commands for gathering system information from the current machine.
|
||||
|
||||
## Basic Device Information
|
||||
|
||||
```bash
|
||||
# Hostname
|
||||
hostname
|
||||
|
||||
# OS/Platform info
|
||||
cat /etc/os-release 2>/dev/null || uname -a
|
||||
|
||||
# Hardware model - Raspberry Pi
|
||||
cat /proc/device-tree/model 2>/dev/null || echo "Unknown"
|
||||
|
||||
# Hardware model - x86 systems
|
||||
cat /sys/class/dmi/id/product_name 2>/dev/null || echo "Unknown"
|
||||
|
||||
# Serial number - Raspberry Pi
|
||||
cat /proc/device-tree/serial-number 2>/dev/null || cat /proc/cpuinfo | grep Serial | cut -d: -f2 | tr -d ' ' 2>/dev/null
|
||||
|
||||
# Serial number - x86 systems
|
||||
cat /sys/class/dmi/id/product_serial 2>/dev/null || echo "Unknown"
|
||||
|
||||
# CPU count
|
||||
nproc
|
||||
|
||||
# Memory in MB
|
||||
free -m | awk '/Mem:/ {print $2}'
|
||||
|
||||
# Disk size in GB (root filesystem)
|
||||
df -BG / | awk 'NR==2 {print $2}' | tr -d 'G'
|
||||
```
|
||||
|
||||
## Network Interfaces
|
||||
|
||||
```bash
|
||||
# Get interfaces with IPs (JSON format)
|
||||
ip -j addr show 2>/dev/null || ip addr show
|
||||
|
||||
# Get default gateway interface
|
||||
ip route | grep default | awk '{print $5}' | head -1
|
||||
|
||||
# Get MAC addresses
|
||||
ip -j link show 2>/dev/null || ip link show
|
||||
```
|
||||
|
||||
## Running Applications
|
||||
|
||||
```bash
|
||||
# Docker containers (JSON format)
|
||||
docker ps --format '{"name":"{{.Names}}","image":"{{.Image}}","status":"{{.Status}}","ports":"{{.Ports}}"}' 2>/dev/null || echo "Docker not available"
|
||||
|
||||
# Docker Compose projects (find compose files)
|
||||
find ~/apps /home/*/apps -name "docker-compose.yml" -o -name "docker-compose.yaml" 2>/dev/null | head -20
|
||||
|
||||
# Running systemd services
|
||||
systemctl list-units --type=service --state=running --no-pager --plain 2>/dev/null | grep -v "^UNIT" | head -30
|
||||
```
|
||||
|
||||
## Interface Type Mapping
|
||||
|
||||
| Interface Pattern | NetBox Type |
|
||||
|-------------------|-------------|
|
||||
| `eth*`, `enp*` | `1000base-t` |
|
||||
| `wlan*` | `ieee802.11ax` |
|
||||
| `tailscale*`, `docker*`, `br-*` | `virtual` |
|
||||
| `lo` | Skip (loopback) |
|
||||
|
||||
## Platform Detection
|
||||
|
||||
Based on OS detected, determine platform name:
|
||||
|
||||
| OS Detection | Platform Name |
|
||||
|--------------|---------------|
|
||||
| Raspberry Pi OS | `Raspberry Pi OS (Bookworm)` |
|
||||
| Ubuntu | `Ubuntu {version} LTS` |
|
||||
| Debian | `Debian {version}` |
|
||||
| Default | `{OS Name} {Version}` |
|
||||
|
||||
## Device Role Auto-Detection
|
||||
|
||||
Based on detected services:
|
||||
|
||||
| Detection | Suggested Role |
|
||||
|-----------|----------------|
|
||||
| Docker containers found | `Docker Host` |
|
||||
| Only basic services | `Server` |
|
||||
| Specific role specified | Use specified |
|
||||
|
||||
## Container Role Mapping
|
||||
|
||||
Map container names/images to roles:
|
||||
|
||||
| Container Pattern | Role |
|
||||
|-------------------|------|
|
||||
| `*caddy*`, `*nginx*`, `*traefik*` | Reverse Proxy |
|
||||
| `*db*`, `*postgres*`, `*mysql*`, `*redis*` | Database |
|
||||
| `*webui*`, `*frontend*` | Web Application |
|
||||
| Others | Infer from image or use "Container" |
|
||||
155
plugins/cmdb-assistant/skills/topology-generation.md
Normal file
155
plugins/cmdb-assistant/skills/topology-generation.md
Normal file
@@ -0,0 +1,155 @@
|
||||
# Topology Generation Skill
|
||||
|
||||
Generate Mermaid diagrams from NetBox data.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Load skill: `mcp-tools-reference`
|
||||
|
||||
## View: Rack Elevation
|
||||
|
||||
### Data Collection
|
||||
|
||||
1. Find rack: `dcim_list_racks name=<name>`
|
||||
2. Get devices: `dcim_list_devices rack_id=<id>`
|
||||
3. Note for each: `position`, `u_height`, `face`, `name`, `role`
|
||||
|
||||
### Mermaid Template
|
||||
|
||||
```mermaid
|
||||
graph TB
|
||||
subgraph rack["Rack: <rack-name> (U<height>)"]
|
||||
direction TB
|
||||
u42["U42: empty"]
|
||||
u41["U41: empty"]
|
||||
u40["U40: server-01 (Server)"]
|
||||
u39["U39: server-01 (cont.)"]
|
||||
u38["U38: switch-01 (Switch)"]
|
||||
end
|
||||
```
|
||||
|
||||
### Rules
|
||||
|
||||
- Mark top U with device name and role
|
||||
- Mark subsequent Us as "(cont.)" for multi-U devices
|
||||
- Empty Us show "empty"
|
||||
|
||||
## View: Network Topology
|
||||
|
||||
### Data Collection
|
||||
|
||||
1. List sites: `dcim_list_sites`
|
||||
2. List devices: `dcim_list_devices site_id=<id>`
|
||||
3. List cables: `dcim_list_cables`
|
||||
4. List interfaces: `dcim_list_interfaces device_id=<id>`
|
||||
|
||||
### Mermaid Template
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
subgraph site1["Site: Home"]
|
||||
router1[("core-router-01<br/>Router")]
|
||||
switch1[["dist-switch-01<br/>Switch"]]
|
||||
server1["web-server-01<br/>Server"]
|
||||
server2["db-server-01<br/>Server"]
|
||||
end
|
||||
|
||||
router1 -->|"eth0 - eth1"| switch1
|
||||
switch1 -->|"gi0/1 - eth0"| server1
|
||||
switch1 -->|"gi0/2 - eth0"| server2
|
||||
```
|
||||
|
||||
### Node Shapes by Role
|
||||
|
||||
| Role | Shape | Mermaid Syntax |
|
||||
|------|-------|----------------|
|
||||
| Router | Cylinder | `[(" ")]` |
|
||||
| Switch | Double brackets | `[[ ]]` |
|
||||
| Server | Rectangle | `[ ]` |
|
||||
| Firewall | Hexagon | `{{ }}` |
|
||||
| Other | Rectangle | `[ ]` |
|
||||
|
||||
### Edge Labels
|
||||
|
||||
Show interface names: `A-side - B-side`
|
||||
|
||||
## View: Site Overview
|
||||
|
||||
### Data Collection
|
||||
|
||||
1. Get site: `dcim_get_site id=<id>`
|
||||
2. List racks: `dcim_list_racks site_id=<id>`
|
||||
3. Count devices per rack: `dcim_list_devices rack_id=<id>`
|
||||
|
||||
### Mermaid Template
|
||||
|
||||
```mermaid
|
||||
graph TB
|
||||
subgraph site["Site: Headquarters"]
|
||||
subgraph row1["Row 1"]
|
||||
rack1["Rack A1<br/>12/42 U used<br/>5 devices"]
|
||||
rack2["Rack A2<br/>20/42 U used<br/>8 devices"]
|
||||
end
|
||||
subgraph row2["Row 2"]
|
||||
rack3["Rack B1<br/>8/42 U used<br/>3 devices"]
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
## View: Full Infrastructure
|
||||
|
||||
### Data Collection
|
||||
|
||||
1. List regions: `dcim_list_regions`
|
||||
2. List sites: `dcim_list_sites`
|
||||
3. Count devices: `dcim_list_devices status=active`
|
||||
|
||||
### Mermaid Template
|
||||
|
||||
```mermaid
|
||||
graph TB
|
||||
subgraph region1["Region: Americas"]
|
||||
site1["Headquarters<br/>3 racks, 25 devices"]
|
||||
site2["Branch Office<br/>1 rack, 5 devices"]
|
||||
end
|
||||
subgraph region2["Region: Europe"]
|
||||
site3["EU Datacenter<br/>10 racks, 100 devices"]
|
||||
end
|
||||
|
||||
site1 -.->|"WAN Link"| site3
|
||||
```
|
||||
|
||||
## Output Format
|
||||
|
||||
Always provide:
|
||||
|
||||
1. **Summary** - Brief description of diagram content
|
||||
2. **Mermaid Code Block** - The diagram code
|
||||
3. **Legend** - Explanation of shapes and colors
|
||||
4. **Data Notes** - Any data quality issues
|
||||
|
||||
### Example Output
|
||||
|
||||
```markdown
|
||||
## Network Topology: Home Site
|
||||
|
||||
This diagram shows network connections between 4 devices at Home site.
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
router1[("core-router<br/>Router")]
|
||||
switch1[["main-switch<br/>Switch"]]
|
||||
server1["homelab-01<br/>Server"]
|
||||
|
||||
router1 -->|"eth0 - gi0/24"| switch1
|
||||
switch1 -->|"gi0/1 - eth0"| server1
|
||||
```
|
||||
|
||||
**Legend:**
|
||||
- Cylinder shape: Routers
|
||||
- Double brackets: Switches
|
||||
- Rectangle: Servers
|
||||
|
||||
**Data Notes:**
|
||||
- 1 device (nas-01) has no cable connections documented
|
||||
```
|
||||
32
plugins/cmdb-assistant/skills/visual-header.md
Normal file
32
plugins/cmdb-assistant/skills/visual-header.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Visual Header Skill
|
||||
|
||||
Standard visual header for cmdb-assistant commands.
|
||||
|
||||
## Header Template
|
||||
|
||||
```
|
||||
+----------------------------------------------------------------------+
|
||||
| CMDB-ASSISTANT - [Context] |
|
||||
+----------------------------------------------------------------------+
|
||||
```
|
||||
|
||||
## Context Values by Command
|
||||
|
||||
| Command | Context |
|
||||
|---------|---------|
|
||||
| `/cmdb-search` | Search |
|
||||
| `/cmdb-device` | Device Management |
|
||||
| `/cmdb-ip` | IP Management |
|
||||
| `/cmdb-site` | Site Management |
|
||||
| `/cmdb-audit` | Data Quality Audit |
|
||||
| `/cmdb-register` | Machine Registration |
|
||||
| `/cmdb-sync` | Machine Sync |
|
||||
| `/cmdb-topology` | Topology |
|
||||
| `/change-audit` | Change Audit |
|
||||
| `/ip-conflicts` | IP Conflict Detection |
|
||||
| `/initial-setup` | Setup Wizard |
|
||||
| Agent mode | Infrastructure Management |
|
||||
|
||||
## Usage
|
||||
|
||||
Display header at the start of every command response before proceeding with the operation.
|
||||
Reference in New Issue
Block a user