soda64 1dbbb1ce56
Build and Publish Release / Build Packages and Publish (push) Successful in 10s
feat: release v1.1.2 - hardened IP sorting with ipaddress and config sort defaults
2026-10-03 22:18:10 +02:00

Inventory Collector (inventory-collector)

Universal homelab and fleet inventory collector and deduplicator for Ansible and linux-connector.


Features

  • 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).

Installation

From Gitea Package Registry (RPM / Fedora / Alma / Rocky)

# Add Wired LAB Gitea repository (/etc/yum.repos.d/gitea-wired.repo)
sudo dnf install -y inventory-collector

From Debian / Ubuntu (.deb)

sudo dpkg -i inventory-collector_1.0.0_all.deb

Standalone Tarball Installer

tar -xzf inventory-collector-1.0.0.tar.gz
cd inventory-collector-1.0.0
sudo ./install.sh

From Source Checkout

git clone https://gitea.wired.synology.me/soda64/inventory-collector.git
cd inventory-collector
pip install -r requirements.txt

Usage

Quick Start

# 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

./bin/inventory-collector --source static_hosts.ini -o inventory/hosts.yaml

Format Selection

# 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:

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

License

MIT

S
Description
Universal homelab and fleet inventory collector and deduplicator for Ansible and linux-connector
Readme
213 KiB
0 Stars 1 Watchers 0 Forks
2026-10-03 23:02:54 +02:00
Languages
Python 96.7%
Shell 3.3%