2 Commits
Author SHA1 Message Date
soda64 d562c09e0c feat: release v1.1.3 - synchronized documentation parity and package release
Build and Publish Release / Build Packages and Publish (push) Successful in 9s
2026-10-03 23:02:46 +02:00
soda64 c116834be9 docs: synchronize README and user guide with v1.1.2 features, sorting, and filtering 2026-10-03 22:24:38 +02:00
7 changed files with 134 additions and 38 deletions

No files matched your search

+48 -18
View File
@@ -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. - **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`. - **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:** - **Multi-Format Exporters:**
- `ansible-yaml`: Native Ansible YAML inventory (`all.children`). - `ansible-yaml`: Native Ansible YAML inventory (`all.children`).
- `ansible-json`: Executable Ansible Dynamic Inventory script format (`--list` with `_meta.hostvars`). - `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. - `yaml`: Clean, generic YAML dictionary.
- `xml`: Well-formed, pretty-printed XML for CMDB and enterprise monitoring tools. - `xml`: Well-formed, pretty-printed XML for CMDB and enterprise monitoring tools.
- `ini`: Standard Ansible INI inventory sections. - `ini`: Standard Ansible INI inventory sections.
- **Simultaneous Target Sync (`--sync`):** Synchronizes both Ansible and `linux-connector` inventories with one command. - **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. - **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 only a single dependency (`PyYAML`). - **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) ### From Debian / Ubuntu (.deb)
```bash ```bash
sudo dpkg -i inventory-collector_1.0.0_all.deb sudo dpkg -i inventory-collector_1.1.3_all.deb
``` ```
### Standalone Tarball Installer ### Standalone Tarball Installer
```bash ```bash
tar -xzf inventory-collector-1.0.0.tar.gz tar -xzf inventory-collector-1.1.3.tar.gz
cd inventory-collector-1.0.0 cd inventory-collector-1.1.3
sudo ./install.sh sudo ./install.sh
``` ```
@@ -56,37 +59,59 @@ pip install -r requirements.txt
### Quick Start ### Quick Start
```bash ```bash
# Print Ansible YAML inventory to stdout # Print Ansible YAML inventory to stdout
./bin/inventory-collector inventory-collector
# Inspect discovered inventory in terminal table (dry run) # Inspect discovered inventory in terminal table (dry run)
./bin/inventory-collector --check inventory-collector --check
# Generate Ansible dynamic inventory JSON for CI/CD # Generate Ansible dynamic inventory JSON for CI/CD
./bin/inventory-collector --list inventory-collector --list
# Synchronize both Ansible and linux-connector files simultaneously # Synchronize both Ansible and linux-connector files simultaneously
./bin/inventory-collector --sync inventory-collector --sync
``` ```
### Static File Ingestion ### Sorting & Filtering
```bash ```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 ### Format Selection
```bash ```bash
# Export to XML # 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 # 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`) ## 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 ```yaml
sources: sources:
@@ -96,17 +121,22 @@ sources:
token_id: "${PROXMOX_TOKEN_ID}" token_id: "${PROXMOX_TOKEN_ID}"
token_secret: "${PROXMOX_TOKEN_SECRET}" token_secret: "${PROXMOX_TOKEN_SECRET}"
verify_ssl: false verify_ssl: false
timeout: 10
static_files: static_files:
- path: "static_hosts.ini" - path: "~/.config/inventory-collector/static_hosts.ini"
required: false required: false
defaults: defaults:
ssh_user: "lain" ssh_user: "lain"
ssh_port: 22 ssh_port: 22
conflict_policy: "runtime_over_static" 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: 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" linux_connector: "~/.config/linux-connector/hosts.yaml"
``` ```
@@ -34,3 +34,7 @@
- Hardened IP sorting with Python standard `ipaddress` module for 32-bit/128-bit numerical sorting. - Hardened IP sorting with Python standard `ipaddress` module for 32-bit/128-bit numerical sorting.
- Handled CIDR prefixes (`/24`) and port numbers (`:22`) cleanly in IP sort key. - Handled CIDR prefixes (`/24`) and port numbers (`:22`) cleanly in IP sort key.
- Added configuration file support for `sort_by` and `sort_reverse` under `defaults:`. - Added configuration file support for `sort_by` and `sort_reverse` under `defaults:`.
- Release v1.1.3:
- Fully synchronized all documentation (README, User Guide, manual page, completions).
- Production release with hardened sorting and full documentation parity.
+67 -10
View File
@@ -39,19 +39,66 @@ synology-nas 192.168.0.2 static:hosts.ini external, storage
| `-o`, `--output` | `PATH` | Write inventory to destination file. Format is inferred from extension (`.xml`, `.ini`, `.json`, `.yaml`). | | `-o`, `--output` | `PATH` | Write inventory to destination file. Format is inferred from extension (`.xml`, `.ini`, `.json`, `.yaml`). |
| `-f`, `--format` | `FORMAT` | Explicit output format: `ansible-yaml` (default), `ansible-json`, `linux-connector`, `yaml`, `xml`, `ini`. | | `-f`, `--format` | `FORMAT` | Explicit output format: `ansible-yaml` (default), `ansible-json`, `linux-connector`, `yaml`, `xml`, `ini`. |
| `-s`, `--source` | `PATH` | Path to static file (`.ini` or `.yaml`). Can be repeated multiple times. | | `-s`, `--source` | `PATH` | Path to static file (`.ini` or `.yaml`). Can be repeated multiple times. |
| `--list` | *none* | Ansible Dynamic Inventory script mode (outputs JSON with `_meta.hostvars` to stdout). | | `--list` | *none* | Ansible Dynamic Inventory script mode (outputs JSON with `_meta.hostvars` to stdout). Stderr is quieted. |
| `--check`, `--dry-run` | *none* | Print summary table to stdout and exit. | | `--check`, `--dry-run` | *none* | Print summary table to stdout and exit without modifying any files. |
| `--sync` | *none* | Update both Ansible (`inventory/hosts.yaml`) and `linux-connector` (`~/.config/linux-connector/hosts.yaml`) simultaneously. | | `--sync` | *none* | Update both Ansible (`destinations.ansible`) and `linux-connector` (`destinations.linux_connector`) simultaneously. |
| `-t`, `--tag`, `--filter-tag` | `TAG` | Filter inventory hosts by tag (case-insensitive, e.g. `hypervisor`, `k3s`). |
| `-g`, `--group`, `--filter-group` | `GROUP` | Filter inventory hosts by group or category name (e.g. `proxmox_vms`, `storage`). |
| `--source-type`, `--origin` | `SOURCE` | Filter hosts by source provider (`proxmox`, `static`, `file`, `k3s`). |
| `--sort`, `--sort-by` | `FIELD` | Sort hosts by `name` or `ip` (default: `name`, or config setting). Evaluates 32-bit/128-bit numerical IP order. |
| `-r`, `--reverse` | *none* | Reverse the sort order. |
| `--ansible-dest` | `PATH` | Target output path for Ansible inventory in `--sync` mode (overrides config). |
| `--lc-dest` | `PATH` | Target output path for linux-connector inventory in `--sync mode` (overrides config). |
| `-q`, `--quiet` | *none* | Silence all informational and warning log messages on stderr. |
| `-v`, `--verbose` | *none* | Enable verbose logging on stderr (forces output even in `--list` mode). |
| `-c`, `--config` | `PATH` | Path to configuration file. Default: `~/.config/inventory-collector/config.yaml`. | | `-c`, `--config` | `PATH` | Path to configuration file. Default: `~/.config/inventory-collector/config.yaml`. |
| `-V`, `--version` | *none* | Show version and exit. | | `-V`, `--version` | *none* | Show version and exit. |
| `-h`, `--help` | *none* | Show help message. | | `-h`, `--help` | *none* | Show help message. |
--- ---
## 3. Configuration File (`config.yaml`) ## 3. Filtering & Sorting
### Filtering Hosts
You can filter hosts in check mode (`--check`), sync mode (`--sync`), or when exporting to any format:
```bash
# Filter by tag:
inventory-collector --check -t hypervisor
# Filter by group / category:
inventory-collector --check -g proxmox_vms
# Filter by source provider (e.g. only hosts discovered via Proxmox):
inventory-collector --check --source-type proxmox
# Combine filters:
inventory-collector --check --source-type proxmox -t k3s -g k3s_cluster
```
### Sorting Hosts
Hosts can be sorted either by hostname or by IP address:
```bash
# Sort alphabetically by hostname (default):
inventory-collector --check --sort name
# Sort numerically by IP address (IPv4 32-bit octets / IPv6):
inventory-collector --check --sort ip
# Reverse sort order:
inventory-collector --check --sort ip -r
```
> [!NOTE]
> IP sorting accurately evaluates full IPv4 octets (`(192, 168, 0, 101) < (192, 168, 5, 51)` because $0 < 5$). CIDR prefixes (`/24`) and ports (`:22`) are automatically stripped before numerical comparison.
---
## 4. Configuration File (`config.yaml`)
Configuration can be stored in: Configuration can be stored in:
- `./inventory-collector.yaml` (current directory) - `./inventory-collector.yaml` (current working directory)
- `~/.config/inventory-collector/config.yaml` (user-level) - `~/.config/inventory-collector/config.yaml` (user-level)
- `/etc/inventory-collector/config.yaml` (system-level) - `/etc/inventory-collector/config.yaml` (system-level)
@@ -74,15 +121,19 @@ defaults:
ssh_user: "lain" ssh_user: "lain"
ssh_port: 22 ssh_port: 22
conflict_policy: "runtime_over_static" 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: 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" linux_connector: "~/.config/linux-connector/hosts.yaml"
``` ```
--- ---
## 4. Integration Examples ## 5. Integration Examples
### Ansible CLI ### Ansible CLI
Use generated static file: Use generated static file:
@@ -100,9 +151,15 @@ Sync directly to `linux-connector`:
```bash ```bash
inventory-collector --format linux-connector -o ~/.config/linux-connector/hosts.yaml inventory-collector --format linux-connector -o ~/.config/linux-connector/hosts.yaml
``` ```
Or run simultaneous sync:
### Simultaneous Sync (`--sync`)
Update both Ansible and `linux-connector` simultaneously:
```bash ```bash
# Uses destinations configured in config.yaml:
inventory-collector --sync inventory-collector --sync
# Or override destinations ad-hoc from CLI:
inventory-collector --sync --ansible-dest /etc/ansible/hosts.yaml --lc-dest ~/.config/linux-connector/hosts.yaml --sort ip
``` ```
### Gitea Actions CI/CD Pipeline ### Gitea Actions CI/CD Pipeline
@@ -114,12 +171,12 @@ In `.gitea/workflows/run-ansible.yml`:
ANSIBLE_PROXMOX_TOKEN_ID: ${{ secrets.ANSIBLE_PROXMOX_TOKEN_ID }} ANSIBLE_PROXMOX_TOKEN_ID: ${{ secrets.ANSIBLE_PROXMOX_TOKEN_ID }}
ANSIBLE_PROXMOX_TOKEN_SECRET: ${{ secrets.ANSIBLE_PROXMOX_TOKEN_SECRET }} ANSIBLE_PROXMOX_TOKEN_SECRET: ${{ secrets.ANSIBLE_PROXMOX_TOKEN_SECRET }}
run: | run: |
inventory-collector --source ansible/inventory/static_hosts.ini -o ansible/inventory/hosts.yaml inventory-collector --source ansible/inventory/static_hosts.ini --sort ip -o ansible/inventory/hosts.yaml
``` ```
--- ---
## 5. Deduplication & Conflict Warnings ## 6. Deduplication & Conflict Warnings
When the same machine is defined in multiple sources (e.g. in a static INI and dynamically discovered via Proxmox): When the same machine is defined in multiple sources (e.g. in a static INI and dynamically discovered via Proxmox):
- **Groups & Tags:** Merged into a unified set. - **Groups & Tags:** Merged into a unified set.
+1 -1
View File
@@ -1,6 +1,6 @@
"""Universal homelab and fleet inventory collector and deduplicator.""" """Universal homelab and fleet inventory collector and deduplicator."""
__version__ = "1.1.2" __version__ = "1.1.3"
_yaml_warning_emitted = False _yaml_warning_emitted = False
+1 -1
View File
@@ -1,4 +1,4 @@
.TH INVENTORY-COLLECTOR 1 "October 2026" "inventory-collector 1.1.2" "User Commands" .TH INVENTORY-COLLECTOR 1 "October 2026" "inventory-collector 1.1.3" "User Commands"
.SH NAME .SH NAME
inventory-collector \- Universal homelab and fleet inventory collector and deduplicator inventory-collector \- Universal homelab and fleet inventory collector and deduplicator
.SH SYNOPSIS .SH SYNOPSIS
+6 -1
View File
@@ -1,5 +1,5 @@
Name: inventory-collector Name: inventory-collector
Version: 1.1.2 Version: 1.1.3
Release: 1%{?dist} Release: 1%{?dist}
Summary: Universal homelab and fleet inventory collector and deduplicator Summary: Universal homelab and fleet inventory collector and deduplicator
@@ -66,6 +66,11 @@ fi
%doc %{_datadir}/doc/inventory-collector %doc %{_datadir}/doc/inventory-collector
%changelog %changelog
* Sat Oct 03 2026 Mateusz Stomski <zbytatencyjny@gmail.com> - 1.1.3-1
- Synchronize comprehensive documentation across README, User Guide, and manual page.
- Harden numerical IP sorting against CIDR masks, port numbers, and IPv6.
- Full configuration file integration for default sorting and destination paths.
* Sat Oct 03 2026 Mateusz Stomski <zbytatencyjny@gmail.com> - 1.1.2-1 * Sat Oct 03 2026 Mateusz Stomski <zbytatencyjny@gmail.com> - 1.1.2-1
- Use Python standard ipaddress module for robust numerical 32-bit/128-bit IP sorting. - Use Python standard ipaddress module for robust numerical 32-bit/128-bit IP sorting.
- Handle CIDR notation (/24) and port numbers (:22) gracefully in IP sorting. - Handle CIDR notation (/24) and port numbers (:22) gracefully in IP sorting.
+7 -7
View File
@@ -33,13 +33,13 @@ class TestPackaging(unittest.TestCase):
def test_get_version(self): def test_get_version(self):
version = get_version(self.source_root) version = get_version(self.source_root)
self.assertEqual(version, "1.1.2") self.assertEqual(version, "1.1.3")
def test_build_tarball(self): def test_build_tarball(self):
builder = PackageBuilder( builder = PackageBuilder(
source_root=self.source_root, source_root=self.source_root,
output_dir=self.output_dir, output_dir=self.output_dir,
version="1.1.2", version="1.1.3",
) )
tar_path = builder.build_tarball() tar_path = builder.build_tarball()
self.assertTrue(tar_path.exists()) self.assertTrue(tar_path.exists())
@@ -48,16 +48,16 @@ class TestPackaging(unittest.TestCase):
# Verify tar contents # Verify tar contents
with tarfile.open(str(tar_path), "r:gz") as tar: with tarfile.open(str(tar_path), "r:gz") as tar:
names = tar.getnames() names = tar.getnames()
self.assertIn("inventory-collector-1.1.2/bin/inventory-collector", names) self.assertIn("inventory-collector-1.1.3/bin/inventory-collector", names)
self.assertIn("inventory-collector-1.1.2/inventory_collector/__init__.py", names) self.assertIn("inventory-collector-1.1.3/inventory_collector/__init__.py", names)
self.assertIn("inventory-collector-1.1.2/install.sh", names) self.assertIn("inventory-collector-1.1.3/install.sh", names)
self.assertIn("inventory-collector-1.1.2/packaging/install.sh", names) self.assertIn("inventory-collector-1.1.3/packaging/install.sh", names)
def test_build_deb(self): def test_build_deb(self):
builder = PackageBuilder( builder = PackageBuilder(
source_root=self.source_root, source_root=self.source_root,
output_dir=self.output_dir, output_dir=self.output_dir,
version="1.1.2", version="1.1.3",
) )
deb_path = builder.build_deb() deb_path = builder.build_deb()
self.assertTrue(deb_path.exists()) self.assertTrue(deb_path.exists())