feat(hosts): re-provision action on reporting hosts; Ansible off the edit page
- Host agent panel (reporting state) gains a "Re-provision" collapsible (admin + linked target + managed key): bootstrap user/password → provision.yml, which reinstalls the steward account + managed key + agent. This is the missing path after regenerating the managed key — Update alone can't fix a broken key. - Remove the Ansible sections (run-playbook + target link) from the host EDIT page — they were the stale free-text version and the wrong place. They live on the host detail hub (dropdown + discovered variables). Edit page now links to the host page; edit_host route simplified (no ansible fetch). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+3
-25
@@ -304,38 +304,16 @@ async def create_host():
|
||||
@hosts_bp.get("/<host_id>/edit")
|
||||
@require_role(UserRole.operator)
|
||||
async def edit_host(host_id: str):
|
||||
from steward.models.ansible_inventory import AnsibleTarget
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
# Pure host config (name/address/monitors). Agent, Ansible target linking,
|
||||
# and playbook runs live on the host detail page (the hub), not here.
|
||||
async with current_app.db_sessionmaker() as db:
|
||||
result = await db.execute(select(Host).where(Host.id == host_id))
|
||||
host = result.scalar_one_or_none()
|
||||
if host is None:
|
||||
return "Not found", 404
|
||||
|
||||
linked_result = await db.execute(
|
||||
select(AnsibleTarget)
|
||||
.where(AnsibleTarget.host_id == host_id)
|
||||
.options(selectinload(AnsibleTarget.groups))
|
||||
)
|
||||
linked_target = linked_result.scalar_one_or_none()
|
||||
|
||||
# Only show targets not yet linked to any host (plus the currently linked one)
|
||||
linkable_result = await db.execute(
|
||||
select(AnsibleTarget)
|
||||
.where(AnsibleTarget.host_id.is_(None))
|
||||
.order_by(AnsibleTarget.name)
|
||||
)
|
||||
linkable_targets = linkable_result.scalars().all()
|
||||
|
||||
return await render_template(
|
||||
"hosts/form.html",
|
||||
host=host,
|
||||
probe_types=list(ProbeType),
|
||||
ansible_sources=_ansible_source_names(),
|
||||
linked_target=linked_target,
|
||||
linkable_targets=linkable_targets,
|
||||
)
|
||||
"hosts/form.html", host=host, probe_types=list(ProbeType))
|
||||
|
||||
|
||||
@hosts_bp.post("/<host_id>")
|
||||
|
||||
Reference in New Issue
Block a user