Files
FabledSteward/steward/templates/ansible/run_detail.html
T
bvandeusenandClaude Opus 5.5 a02f224f22
CI / lint (push) Successful in 3s
CI / integration (push) Successful in 1m25s
CI / unit (push) Successful in 1m46s
CI / publish (push) Successful in 1m9s
feat(ansible): one strip of tabs, a run list that opens on its verdict, a run page in one line (#5328, #5329, #5330)
- section_tabs macro; Runs · Playbooks · Schedules · Inventory on every
  Ansible page, replacing each page's own set of header buttons.
- Runs: a verdict line (last 30 days, failures first with the latest named,
  running now, the schedule due next); under each status what the run did
  across its hosts (ansible/recap.py); a filter bar (playbook, status, who
  started it) that swaps the table and carries into the scroll paging.
- Run page: status, duration, start and who started it in one line; each
  host's result in words, worst first; the playbook it ran links to it;
  the log and failures on classes rather than inline colours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 23:45:04 -04:00

101 lines
5.1 KiB
HTML

{# ansible/run_detail.html — one run (#5330): a verdict line (how it ended,
how long, when, who started it, what it did across its hosts), what it ran
with, each host's result in words, worst first, then its output. #}
{% extends "base.html" %}
{% from "_macros.html" import crumbs, page_header, status_badge %}
{% from "ansible/_tabs.html" import ansible_tabs %}
{% block title %}{{ row.title }} — Steward{% endblock %}
{% block breadcrumb %}{{ crumbs([("Ansible", "/ansible/"), (row.title, "")]) }}{% endblock %}
{% macro words(parts) -%}
{% for text, tone in parts %}{% if not loop.first %} · {% endif %}{% if tone %}<span class="tone-{{ tone }}">{{ text }}</span>{% else %}{{ text }}{% endif %}{% endfor %}
{%- endmacro %}
{% block content %}
{{ ansible_tabs("runs") }}
{% call page_header(row.title) %}
{% if run.status.value in ("running", "queued") and session.user_role in ("operator", "admin") %}
<form method="post" action="/ansible/runs/{{ run.id }}/cancel" data-confirm="Cancel this run? Ansible stops where it is; tasks already applied stay applied." data-confirm-dismiss="Keep running">{{ csrf_field() }}
<button type="submit" class="btn btn-sm btn-danger">Cancel run</button>
</form>
{% endif %}
<a href="/ansible/runs/{{ run.id }}/log" class="btn btn-sm btn-ghost">Download log</a>
{% endcall %}
<p class="page-verdict">
{{- status_badge(run.status) }}
{%- if row.check %} <span class="tone-info" title="Ansible check mode: nothing was changed">dry run</span>{% endif %}
{%- if row.duration_s is not none %} {% if run.finished_at %}in{% else %}for{% endif %} {{ row.duration_s|duration }}{% if not run.finished_at %} so far{% endif %}{% endif %}
· started {{ run.started_at|ago }}
· by {% if origin.url %}<a href="{{ origin.url }}">{{ origin.text }}</a>{% else %}{{ origin.text }}{% endif %}
{%- if row.recap %} · {{ words(row.recap) }}{% endif -%}
</p>
<div class="card">
<dl class="kv">
<dt>Playbook</dt><dd><a href="/ansible/browse/{{ run.source_name }}/{{ run.playbook_path }}">{{ run.playbook_path }}</a> <span class="tone-dim">from {{ run.source_name }}</span></dd>
<dt>On</dt><dd>{{ row.scope_label }}</dd>
{% if run.params %}
{% if run.params.limit %}<dt>Limit</dt><dd class="mono">{{ run.params.limit }}</dd>{% endif %}
{% if run.params.tags %}<dt>Tags</dt><dd class="mono">{{ run.params.tags }}</dd>{% endif %}
{% if run.params.extra_vars %}<dt>Extra vars</dt><dd class="mono">{{ run.params.extra_vars | join(", ") }}</dd>{% endif %}
{% endif %}
</dl>
</div>
{% if hosts %}
<section class="card-flush" aria-labelledby="run-hosts">
<h2 id="run-hosts" class="table-caption">Hosts <span class="tone-muted">worst first</span></h2>
<table class="table">
<thead><tr><th>Host</th><th>Result</th></tr></thead>
<tbody>
{% for host, parts in hosts %}
<tr><td class="mono">{{ host }}</td><td>{{ words(parts) if parts else '—' }}</td></tr>
{% endfor %}
</tbody>
</table>
</section>
{% endif %}
{% if run.results and run.results.failures %}
<section class="card" aria-labelledby="run-failures">
<h2 id="run-failures" class="section-title">What failed</h2>
<pre class="run-log run-failures">{{ run.results.failures | join("\n") }}</pre>
</section>
{% endif %}
<section class="card-flush" aria-labelledby="run-output">
<h2 id="run-output" class="table-caption">Output</h2>
{% if run.status.value in ("running", "queued") %}
<pre id="live-output" class="run-log">{{ run.output or "" }}</pre>
<p id="run-done-status" class="field-hint run-log-status">Streaming…</p>
<script>
(function() {
var es = new EventSource('/ansible/runs/{{ run.id }}/stream');
var pre = document.getElementById('live-output');
var status = document.getElementById('run-done-status');
// Follow new lines only while the reader is at the bottom; scrolled
// up to read something, they keep their place.
es.addEventListener('output', function(e) {
var atBottom = pre.scrollHeight - pre.scrollTop - pre.clientHeight < 24;
pre.textContent += e.data + '\n';
if (atBottom) pre.scrollTop = pre.scrollHeight;
});
// Finished: load the page again, so the status, duration and host
// summary are the run's final ones rather than "Running". The
// executor saves the final status before it says done; should that
// save have failed, ?finished stops a second reload going round.
es.addEventListener('done', function(e) {
es.close();
if (window.location.search.indexOf('finished=1') === -1) {
status.textContent = 'Finished. Loading the summary…';
window.location.replace(window.location.pathname + '?finished=1');
} else {
status.textContent = 'Finished (' + e.data + '), but the summary could not be saved.';
}
});
})();
</script>
{% else %}
<pre class="run-log">{{ run.output or "(no output)" }}</pre>
{% endif %}
</section>
{% endblock %}