feat: release v1.1.1 - host sorting by name/IP, sync destination overrides, and ~ expansion
Build and Publish Release / Build Packages and Publish (push) Successful in 25s

This commit is contained in:
soda64 committed 2026-10-03 22:05:00 +02:00
1 parent 598e5d7397
commit 62710d8bb7
19 files changed
+190 -34

No files matched your search

+26
View File
@@ -56,3 +56,29 @@ class InventoryData:
continue
filtered.add_host(host)
return filtered
def sort(self, sort_by: str = "name", reverse: bool = False) -> "InventoryData":
sorted_inv = InventoryData()
def ip_sort_key(ip: str):
clean_ip = (ip or "").strip()
if not clean_ip:
return (1, ())
try:
parts = tuple(int(p) for p in clean_ip.split("."))
if len(parts) == 4:
return (0, parts)
except Exception:
pass
return (2, clean_ip)
def record_key(host: HostRecord):
if sort_by.lower() == "ip":
return (ip_sort_key(host.ansible_host), host.name.lower())
return (host.name.lower(), ip_sort_key(host.ansible_host))
sorted_records = sorted(self.hosts.values(), key=record_key, reverse=reverse)
for host in sorted_records:
sorted_inv.add_host(host)
return sorted_inv