fix(ansible): write DB inventory as static YAML, not dynamic --list JSON
generate_inventory() emits Ansible's dynamic --list shape (all.hosts is a
LIST, vars under _meta) — valid only as an executable inventory script's
stdout. We were writing it to a static file and passing -i, so Ansible's yaml
plugin rejected it ("Invalid 'hosts' entry for 'all' group, requires a
dictionary, found ...list...") and fell back to implicit localhost → "no hosts
matched". Affected every steward:* scope run; surfaced on the first real
provision.
- New inventory_to_yaml(inv): convert the --list dict → a valid static YAML
inventory (all.hosts dict keyed by host, groups under all.children, group
vars preserved, injected per-host vars like steward_token retained).
- Wire it into runner.trigger_run, host_agent deploy + provision.
- executor writes the file as inventory.yml so the yaml plugin's extension
check reliably claims it.
- generate_inventory unchanged (still the --list dict); conversion happens at
write time. Unit tests added.
Scribe issue #885.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -375,7 +375,9 @@ async def start_run(
|
||||
os.chmod(tmpdir, 0o700)
|
||||
try:
|
||||
if inventory_content:
|
||||
inv_target = os.path.join(tmpdir, "inventory")
|
||||
# .yml so Ansible's yaml inventory plugin reliably claims it
|
||||
# (the plugin's verify_file checks the extension).
|
||||
inv_target = os.path.join(tmpdir, "inventory.yml")
|
||||
with open(inv_target, "w", encoding="utf-8") as invf:
|
||||
invf.write(inventory_content)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user