docs: synchronize README and user guide with v1.1.2 features, sorting, and filtering
This commit is contained in:
1 parent
1dbbb1ce56
commit
c116834be9
2 files changed
+115
-28
No files matched your search
@@ -8,7 +8,10 @@ Universal homelab and fleet inventory collector and deduplicator for **Ansible**
|
||||
|
||||
- **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.
|
||||
- **4-Tier IP Resolution:** QEMU Guest Agent $\rightarrow$ PVE hardware config (`ipconfig0`) $\rightarrow$ Static definitions $\rightarrow$ Local DNS resolution with wildcard NXDOMAIN collision protection.
|
||||
- **Filtering & Selective Querying:** Filter inventory dynamically by tag (`-t`), group/category (`-g`), or source provider (`--source-type {proxmox,static,k3s}`).
|
||||
- **Mathematical IP & Name Sorting:** Sort hosts by name or IP (`--sort {name,ip}`, `-r/--reverse`). IP sorting accurately evaluates IPv4 octets (32-bit integer) and IPv6 addresses, handling CIDR prefixes (`/24`) and ports (`:22`).
|
||||
- **Clean YAML (No Anchors):** Generates clean, human-readable YAML without YAML anchors or aliases (`&id`/`*id`).
|
||||
- **Multi-Format Exporters:**
|
||||
- `ansible-yaml`: Native Ansible YAML inventory (`all.children`).
|
||||
- `ansible-json`: Executable Ansible Dynamic Inventory script format (`--list` with `_meta.hostvars`).
|
||||
@@ -16,9 +19,9 @@ Universal homelab and fleet inventory collector and deduplicator for **Ansible**
|
||||
- `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`).
|
||||
- **Simultaneous Target Sync (`--sync`):** Synchronizes both Ansible and `linux-connector` inventories with one command, with customizable destination paths (`--ansible-dest`, `--lc-dest`) and `~` home directory expansion.
|
||||
- **Zero-Secrets Policy:** Credentials read from environment variables (`PROXMOX_*`, `ANSIBLE_PROXMOX_*`) or configuration files with variable interpolation and automatic `.env` loading.
|
||||
- **Lean Runtime:** Pure Python 3 standard library with optional `PyYAML` acceleration.
|
||||
|
||||
---
|
||||
|
||||
@@ -32,13 +35,13 @@ sudo dnf install -y inventory-collector
|
||||
|
||||
### From Debian / Ubuntu (.deb)
|
||||
```bash
|
||||
sudo dpkg -i inventory-collector_1.0.0_all.deb
|
||||
sudo dpkg -i inventory-collector_1.1.2_all.deb
|
||||
```
|
||||
|
||||
### Standalone Tarball Installer
|
||||
```bash
|
||||
tar -xzf inventory-collector-1.0.0.tar.gz
|
||||
cd inventory-collector-1.0.0
|
||||
tar -xzf inventory-collector-1.1.2.tar.gz
|
||||
cd inventory-collector-1.1.2
|
||||
sudo ./install.sh
|
||||
```
|
||||
|
||||
@@ -56,37 +59,59 @@ pip install -r requirements.txt
|
||||
### Quick Start
|
||||
```bash
|
||||
# Print Ansible YAML inventory to stdout
|
||||
./bin/inventory-collector
|
||||
inventory-collector
|
||||
|
||||
# Inspect discovered inventory in terminal table (dry run)
|
||||
./bin/inventory-collector --check
|
||||
inventory-collector --check
|
||||
|
||||
# Generate Ansible dynamic inventory JSON for CI/CD
|
||||
./bin/inventory-collector --list
|
||||
inventory-collector --list
|
||||
|
||||
# Synchronize both Ansible and linux-connector files simultaneously
|
||||
./bin/inventory-collector --sync
|
||||
inventory-collector --sync
|
||||
```
|
||||
|
||||
### Static File Ingestion
|
||||
### Sorting & Filtering
|
||||
```bash
|
||||
./bin/inventory-collector --source static_hosts.ini -o inventory/hosts.yaml
|
||||
# Sort hosts mathematically by IP address (numerical 32-bit order)
|
||||
inventory-collector --check --sort ip
|
||||
|
||||
# Filter only Proxmox VMs tagged with 'k3s'
|
||||
inventory-collector --check --source-type proxmox -t k3s
|
||||
|
||||
# Filter by group and sort by IP in reverse order
|
||||
inventory-collector -g storage --sort ip -r
|
||||
|
||||
# Export filtered inventory to Ansible YAML
|
||||
inventory-collector -t production --sort ip -o inventory/production.yaml
|
||||
```
|
||||
|
||||
### Synchronization & Custom Destinations
|
||||
```bash
|
||||
# Sync with explicit destination paths
|
||||
inventory-collector --sync --ansible-dest ~/.config/inventory-collector/hosts.yaml --lc-dest ~/.config/linux-connector/hosts.yaml
|
||||
|
||||
# Sync with custom Ansible path using short flag -o
|
||||
inventory-collector --sync -o /etc/ansible/hosts.yaml --sort ip
|
||||
```
|
||||
|
||||
### Format Selection
|
||||
```bash
|
||||
# Export to XML
|
||||
./bin/inventory-collector --format xml -o fleet.xml
|
||||
inventory-collector --format xml --sort ip -o fleet.xml
|
||||
|
||||
# Export to INI
|
||||
inventory-collector --format ini --sort ip -o hosts.ini
|
||||
|
||||
# Export to linux-connector
|
||||
./bin/inventory-collector --format linux-connector -o ~/.config/linux-connector/hosts.yaml
|
||||
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`:
|
||||
Store configuration in `~/.config/inventory-collector/config.yaml`, `/etc/inventory-collector/config.yaml`, or `./inventory-collector.yaml`:
|
||||
|
||||
```yaml
|
||||
sources:
|
||||
@@ -96,17 +121,22 @@ sources:
|
||||
token_id: "${PROXMOX_TOKEN_ID}"
|
||||
token_secret: "${PROXMOX_TOKEN_SECRET}"
|
||||
verify_ssl: false
|
||||
timeout: 10
|
||||
static_files:
|
||||
- path: "static_hosts.ini"
|
||||
- path: "~/.config/inventory-collector/static_hosts.ini"
|
||||
required: false
|
||||
|
||||
defaults:
|
||||
ssh_user: "lain"
|
||||
ssh_port: 22
|
||||
conflict_policy: "runtime_over_static"
|
||||
sort_by: "ip" # Default sorting: "name" or "ip"
|
||||
sort_reverse: false # Set true to reverse sort order by default
|
||||
|
||||
destinations:
|
||||
ansible: "inventory/hosts.yaml"
|
||||
# In --sync mode, destinations define where unified inventories are written.
|
||||
# Supports '~' home expansion or absolute paths:
|
||||
ansible: "~/.config/inventory-collector/hosts.yaml"
|
||||
linux_connector: "~/.config/linux-connector/hosts.yaml"
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user