{# Per-host agent panel — embedded into /hosts/ via HTMX. Self-contained. #} {% set scope = "steward:target:" ~ target.id if target else "" %}

Agent

{% if reporting %} {{ 'stale' if stale else 'reporting' }}{% if reg.agent_version %} · v{{ reg.agent_version }}{% endif %} · last seen {{ reg.last_seen_at.strftime('%Y-%m-%d %H:%M') }} {% elif reg %} pending — no check-in yet {% endif %}
{% if reporting %} {# ── Reporting: at-a-glance metrics (+ sparkline trend) + lifecycle ── #} {% set cpu = hostlvl.get('cpu_pct') %} {% set mem = hostlvl.get('mem_used_pct') %} {% set lbl = "font-size:0.72rem;color:var(--text-muted);text-transform:uppercase;" %}
CPU
{{ '%.0f%%'|format(cpu) if cpu is not none else '—' }}
{{ sparks.cpu | safe }}
Memory
{{ '%.0f%%'|format(mem) if mem is not none else '—' }}
{{ sparks.mem | safe }}
Disk /
{{ '%.0f%%'|format(disk_root) if disk_root is not none else '—' }}
{{ sparks.disk | safe }}
Load /core
{{ '%d%%'|format(load_per_core) if load_per_core is not none else ('%.2f'|format(load1) if load1 is not none else '—') }}
{{ sparks.load | safe }}
{% if psi.cpu is not none or psi.mem is not none or psi.io is not none %}
Pressure 10s  CPU {{ '%.0f%%'|format(psi.cpu) if psi.cpu is not none else '—' }} · Mem {{ '%.0f%%'|format(psi.mem) if psi.mem is not none else '—' }} · IO {{ '%.0f%%'|format(psi.io) if psi.io is not none else '—' }}
{% endif %}
Full metrics → {% if session.user_role == 'admin' %} {% if ansible_available and target %}
{% endif %}
{% endif %}
{% if ansible_available and not target %}

Link an Ansible target (above) to enable one-click agent updates.

{% endif %} {% if session.user_role == 'admin' and ansible_available and target and managed_key_set %}
Re-provision (reinstall the steward account + managed key, then the agent)

Use after regenerating the managed key, or if SSH auth as steward breaks. Connects over a one-time bootstrap user + password (not stored).

{% endif %} {% else %} {# ── Not reporting: pending (token minted, no check-in) or never installed ── #} {% if reg %}
A token was minted for this host but no metrics have arrived yet — the deploy may still be running, or it failed. Open the latest Ansible run to check, then retry below. Live metrics appear here once the agent checks in.
{% else %}

No agent installed. The agent reports CPU, memory, disk, network and more back to Steward.

{% endif %} {% if session.user_role != 'admin' %}

An admin can install the agent here.

{% elif not ansible_available %}

Ansible isn't available, so the agent can't be deployed from here. Install it manually with the curl install command.

{% elif not managed_key_set %}
No managed SSH key yet — Steward needs one to log into hosts.
{% elif not target %}

Link or create an Ansible target for this host (in the Ansible section below) first — provisioning needs an SSH connection.

{% else %}

Deploys the agent to {{ target.name }} by running an Ansible playbook. Steward mints the host's API token automatically; you'll watch the run live.

{# Provision: brand-new host (creates steward account + key over a one-time password) #}
Provision (first contact — fresh host):
{# Install: host already has the steward account (managed key works) #}
Already provisioned?
{% endif %} {% if reg and session.user_role == 'admin' %}
{% endif %} {% endif %}