[GEMINI-HARDEN-01] Replace hard-coded fleet inventory with repo-native config
Some checks failed
Smoke Test / smoke (pull_request) Failing after 23s
Architecture Lint / Linter Tests (pull_request) Successful in 26s
Validate Config / YAML Lint (pull_request) Failing after 15s
Validate Config / JSON Validate (pull_request) Successful in 19s
Validate Config / Python Syntax & Import Check (pull_request) Failing after 1m1s
Validate Config / Python Test Suite (pull_request) Has been skipped
Validate Config / Shell Script Lint (pull_request) Failing after 1m4s
Validate Config / Cron Syntax Check (pull_request) Successful in 13s
Validate Config / Deploy Script Dry Run (pull_request) Successful in 13s
Validate Config / Playbook Schema Validation (pull_request) Successful in 25s
Architecture Lint / Lint Repository (pull_request) Failing after 22s
PR Checklist / pr-checklist (pull_request) Successful in 5m0s
Some checks failed
Smoke Test / smoke (pull_request) Failing after 23s
Architecture Lint / Linter Tests (pull_request) Successful in 26s
Validate Config / YAML Lint (pull_request) Failing after 15s
Validate Config / JSON Validate (pull_request) Successful in 19s
Validate Config / Python Syntax & Import Check (pull_request) Failing after 1m1s
Validate Config / Python Test Suite (pull_request) Has been skipped
Validate Config / Shell Script Lint (pull_request) Failing after 1m4s
Validate Config / Cron Syntax Check (pull_request) Successful in 13s
Validate Config / Deploy Script Dry Run (pull_request) Successful in 13s
Validate Config / Playbook Schema Validation (pull_request) Successful in 25s
Architecture Lint / Lint Repository (pull_request) Failing after 22s
PR Checklist / pr-checklist (pull_request) Successful in 5m0s
Add fleet.inventory and fleet.path_contracts to config.yaml: - Central source of truth for IPs, ports, roles, remote paths - Introduce get_config_path(), load_fleet_inventory(), get_path_contract() - Updated fleet_llama.py, self_healing.py, telemetry.py, agent_dispatch.py, skill_installer.py to read from config instead of hard-coded dicts/paths - Documented inventory contract and override mechanism in scripts/README.md Scripts retain forward-compatible fallback defaults for backwards compatibility. Closes #433
This commit is contained in:
@@ -15,12 +15,46 @@ if SCRIPT_DIR not in sys.path:
|
||||
sys.path.insert(0, SCRIPT_DIR)
|
||||
|
||||
from ssh_trust import VerifiedSSHExecutor
|
||||
import yaml
|
||||
|
||||
# --- CONFIGURATION ---
|
||||
FLEET = {
|
||||
"allegro": "167.99.126.228",
|
||||
"bezalel": "159.203.146.185"
|
||||
}
|
||||
|
||||
def get_config_path():
|
||||
return os.environ.get('TIMMY_CONFIG') or os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), '..', 'config.yaml'
|
||||
)
|
||||
|
||||
def load_fleet_inventory():
|
||||
"""Return {{host: ip}} map from config.yaml or fallback defaults."""
|
||||
try:
|
||||
with open(get_config_path(), 'r') as f:
|
||||
cfg = yaml.safe_load(f)
|
||||
inv = cfg.get('fleet', {}).get('inventory', {})
|
||||
if inv:
|
||||
return {k: v['ip'] for k, v in inv.items()}
|
||||
except Exception:
|
||||
pass
|
||||
return {
|
||||
"mac": "10.1.10.77",
|
||||
"ezra": "143.198.27.163",
|
||||
"allegro": "167.99.126.228",
|
||||
"bezalel": "159.203.146.185",
|
||||
}
|
||||
FLEET = load_fleet_inventory()
|
||||
|
||||
|
||||
|
||||
def get_path_contract(key, default):
|
||||
import yaml, os
|
||||
config_path = get_config_path()
|
||||
try:
|
||||
with open(config_path, 'r') as f:
|
||||
cfg = yaml.safe_load(f)
|
||||
return cfg.get('fleet', {}).get('path_contracts', {}).get(key, default)
|
||||
except Exception:
|
||||
return default
|
||||
|
||||
REMOTE_ROOT = get_path_contract('hermes_remote', '/opt/hermes')
|
||||
|
||||
class Dispatcher:
|
||||
def __init__(self, executor=None):
|
||||
@@ -38,7 +72,7 @@ class Dispatcher:
|
||||
res = self.executor.run(
|
||||
ip,
|
||||
['python3', 'run_agent.py', '--agent', agent_name, '--task', task],
|
||||
cwd='/opt/hermes',
|
||||
cwd=REMOTE_ROOT,
|
||||
timeout=30,
|
||||
)
|
||||
if res.returncode == 0:
|
||||
|
||||
Reference in New Issue
Block a user