feat(slice-1): implement tracer bullet pipeline with PyYAML check and pure-python fallback
This commit is contained in:
1 parent
937acc2548
commit
68802710b0
12 files changed
+331
-1
No files matched your search
@@ -0,0 +1,35 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, List, Optional, Any
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class HostRecord:
|
||||
name: str
|
||||
ansible_host: str
|
||||
ansible_user: str = "lain"
|
||||
ansible_port: int = 22
|
||||
ansible_ssh_private_key_file: Optional[str] = None
|
||||
groups: List[str] = field(default_factory=list)
|
||||
tags: List[str] = field(default_factory=list)
|
||||
description: str = ""
|
||||
variables: Dict[str, Any] = field(default_factory=dict)
|
||||
source: str = "unknown"
|
||||
|
||||
@dataclass
|
||||
class InventoryData:
|
||||
hosts: Dict[str, HostRecord] = field(default_factory=dict)
|
||||
groups: Dict[str, List[str]] = field(default_factory=dict)
|
||||
|
||||
def add_host(self, host: HostRecord) -> None:
|
||||
self.hosts[host.name] = host
|
||||
for group in host.groups:
|
||||
if group not in self.groups:
|
||||
self.groups[group] = []
|
||||
if host.name not in self.groups[group]:
|
||||
self.groups[group].append(host.name)
|
||||
|
||||
def get_host(self, name: str) -> Optional[HostRecord]:
|
||||
return self.hosts.get(name)
|
||||
|
||||
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]
|
||||
Reference in new issue
Block a user