feat: release v1.1.0 - clean YAML, wildcard DNS protection, and tag/group/source filtering
Build and Publish Release / Build Packages and Publish (push) Successful in 9s
Build and Publish Release / Build Packages and Publish (push) Successful in 9s
This commit is contained in:
1 parent
5fedc44c6b
commit
598e5d7397
18 files changed
+318
-22
No files matched your search
@@ -33,3 +33,26 @@ class InventoryData:
|
||||
def get_hosts_by_group(self, group: str) -> List[HostRecord]:
|
||||
host_names = self.groups.get(group, [])
|
||||
return [self.hosts[name] for name in host_names if name in self.hosts]
|
||||
|
||||
def filter(
|
||||
self,
|
||||
tag: Optional[str] = None,
|
||||
group: Optional[str] = None,
|
||||
source: Optional[str] = None
|
||||
) -> "InventoryData":
|
||||
filtered = InventoryData()
|
||||
for host in self.hosts.values():
|
||||
if tag and not any(tag.lower() == t.lower() for t in host.tags):
|
||||
continue
|
||||
if group and not any(group.lower() == g.lower() for g in host.groups):
|
||||
continue
|
||||
if source:
|
||||
s_lower = source.lower()
|
||||
if s_lower in ("file", "plik"):
|
||||
match_source = "static" in host.source.lower()
|
||||
else:
|
||||
match_source = s_lower in host.source.lower()
|
||||
if not match_source:
|
||||
continue
|
||||
filtered.add_host(host)
|
||||
return filtered
|
||||
Reference in new issue
Block a user