feat(slice-6): implement config loader, CLI check mode, comprehensive documentation, and shell completions
This commit is contained in:
1 parent
869fd241e7
commit
e5784db650
9 files changed
+616
-29
No files matched your search
@@ -1,22 +1,103 @@
|
||||
# Inventory Collector (`inventory-collector`)
|
||||
|
||||
Universal homelab and fleet inventory collector and deduplicator for Ansible and `linux-connector`.
|
||||
Universal homelab and fleet inventory collector and deduplicator for **Ansible** and **`linux-connector`**.
|
||||
|
||||
## Overview
|
||||
---
|
||||
|
||||
`inventory-collector` queries infrastructure sources (Proxmox VE REST API, static YAML/INI files), normalizes and deduplicates host records in memory, and generates unified inventory files for:
|
||||
- **Ansible:** Playbook execution (`-i hosts.yaml`) and dynamic inventory mode (`--list`).
|
||||
- **`linux-connector`:** Interactive TUI fuzzy launcher and fleet command runner (`hosts.yaml`).
|
||||
- **Standard Exports:** Clean generic YAML and formatted XML for external tooling and CMDBs.
|
||||
## Features
|
||||
|
||||
## Architecture & Plans
|
||||
- **Multi-Source Discovery:** Gathers physical hosts, virtual machines, and LXC containers dynamically from Proxmox VE REST API, alongside static Ansible INI and YAML files.
|
||||
- **In-Memory Deduplication:** Automatically merges host records across sources, calculates group and tag unions, and flags IP/user conflicts on `stderr`.
|
||||
- **4-Tier IP Resolution:** QEMU Guest Agent $\rightarrow$ PVE hardware config (`ipconfig0`) $\rightarrow$ Static definitions $\rightarrow$ Local DNS resolution.
|
||||
- **Multi-Format Exporters:**
|
||||
- `ansible-yaml`: Native Ansible YAML inventory (`all.children`).
|
||||
- `ansible-json`: Executable Ansible Dynamic Inventory script format (`--list` with `_meta.hostvars`).
|
||||
- `linux-connector`: Native `hosts.yaml` for instant pairing with `linux-connector`.
|
||||
- `yaml`: Clean, generic YAML dictionary.
|
||||
- `xml`: Well-formed, pretty-printed XML for CMDB and enterprise monitoring tools.
|
||||
- `ini`: Standard Ansible INI inventory sections.
|
||||
- **Simultaneous Target Sync (`--sync`):** Synchronizes both Ansible and `linux-connector` inventories with one command.
|
||||
- **Zero-Secrets Policy:** Credentials read from environment variables (`PROXMOX_*`, `ANSIBLE_PROXMOX_*`) or configuration files with variable interpolation.
|
||||
- **Lean Runtime:** Pure Python 3 standard library with only a single dependency (`PyYAML`).
|
||||
|
||||
The project follows the Software Factory 4-Gate Workflow:
|
||||
- [00-status.md](docs/plans/inventory-collector/00-status.md) — Implementation status and slice progress.
|
||||
- [01-spec.md](docs/plans/inventory-collector/01-spec.md) — Product specification and CLI interfaces.
|
||||
- [02-architecture.md](docs/plans/inventory-collector/02-architecture.md) — Technical architecture and data models.
|
||||
- [03-program-design.md](docs/plans/inventory-collector/03-program-design.md) — Program design, signatures, and test plan.
|
||||
- [04-slices.md](docs/plans/inventory-collector/04-slices.md) — Vertical slice execution plan.
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
git clone https://gitea.wired.synology.me/soda64/inventory-collector.git
|
||||
cd inventory-collector
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
### Quick Start
|
||||
```bash
|
||||
# Print Ansible YAML inventory to stdout
|
||||
./bin/inventory-collector
|
||||
|
||||
# Inspect discovered inventory in terminal table (dry run)
|
||||
./bin/inventory-collector --check
|
||||
|
||||
# Generate Ansible dynamic inventory JSON for CI/CD
|
||||
./bin/inventory-collector --list
|
||||
|
||||
# Synchronize both Ansible and linux-connector files simultaneously
|
||||
./bin/inventory-collector --sync
|
||||
```
|
||||
|
||||
### Static File Ingestion
|
||||
```bash
|
||||
./bin/inventory-collector --source static_hosts.ini -o inventory/hosts.yaml
|
||||
```
|
||||
|
||||
### Format Selection
|
||||
```bash
|
||||
# Export to XML
|
||||
./bin/inventory-collector --format xml -o fleet.xml
|
||||
|
||||
# Export to linux-connector
|
||||
./bin/inventory-collector --format linux-connector -o ~/.config/linux-connector/hosts.yaml
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuration (`config.yaml`)
|
||||
|
||||
Store configuration in `~/.config/inventory-collector/config.yaml` or `./inventory-collector.yaml`:
|
||||
|
||||
```yaml
|
||||
sources:
|
||||
proxmox:
|
||||
enabled: true
|
||||
url: "${PROXMOX_URL}"
|
||||
token_id: "${PROXMOX_TOKEN_ID}"
|
||||
token_secret: "${PROXMOX_TOKEN_SECRET}"
|
||||
verify_ssl: false
|
||||
static_files:
|
||||
- path: "static_hosts.ini"
|
||||
required: false
|
||||
|
||||
defaults:
|
||||
ssh_user: "lain"
|
||||
ssh_port: 22
|
||||
conflict_policy: "runtime_over_static"
|
||||
|
||||
destinations:
|
||||
ansible: "inventory/hosts.yaml"
|
||||
linux_connector: "~/.config/linux-connector/hosts.yaml"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
- [User Guide](docs/user-guide.md) — Complete operational manual and examples.
|
||||
- [UNIX Manual Page](man/inventory-collector.1) — Section 1 manual page.
|
||||
- [Software Factory Plans](docs/plans/inventory-collector/) — Architecture, specifications, and design documents.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
Reference in new issue
Block a user