389002fc6f
Adds a breadcrumb trail to nested views for orientation. Mechanism: a
{% block breadcrumb %} slot in base.html (+ styling) and a shared crumbs()
macro in templates/_macros.html; each nested page fills the block with its
trail (root→current, last item is the current page). Pages without the block
render no bar, so top-level nav roots stay clean.
Applied to: Ansible (browse, schedules, playbook editor, run detail) +
inventory (targets/groups + detail), host_agent (fleet, host detail,
settings), hosts form, settings tabs (ansible/auth/notifications/plugins/
reports + plugin detail), dashboard (list, edit), and alerts (rule form,
maintenance + new). Dynamic labels (host/target/run/dashboard names) come
from the page context — no route changes. All 60 templates Jinja-compile.
Task #873.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
141 lines
7.3 KiB
HTML
141 lines
7.3 KiB
HTML
{% extends "base.html" %}
|
|
{% from "_macros.html" import crumbs %}
|
|
{% block title %}{% if host %}Edit Host{% else %}New Host{% endif %} — Steward{% endblock %}
|
|
{% block breadcrumb %}{{ crumbs([("Hosts", "/hosts/"), (("Edit " ~ host.name) if host else "New host", "")]) }}{% endblock %}
|
|
{% block content %}
|
|
<div style="max-width:560px;margin:2rem auto;">
|
|
<h1 class="page-title">{% if host %}Edit Host{% else %}Add Host{% endif %}</h1>
|
|
<div class="card">
|
|
<form method="post" action="{% if host %}/hosts/{{ host.id }}{% else %}/hosts/{% endif %}">
|
|
<div class="form-group">
|
|
<label>Display Name</label>
|
|
<input type="text" name="name" value="{{ host.name if host else '' }}" required autofocus>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Address (hostname or IP)</label>
|
|
<input type="text" name="address" value="{{ host.address if host else '' }}" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Probe Type</label>
|
|
<select name="probe_type">
|
|
{% for pt in probe_types %}
|
|
<option value="{{ pt.value }}" {% if host and host.probe_type == pt %}selected{% endif %}>
|
|
{{ pt.value | upper }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>TCP Port (used for TCP probe; ignored for ICMP)</label>
|
|
<input type="number" name="probe_port" value="{{ host.probe_port if host else 80 }}" min="1" max="65535">
|
|
</div>
|
|
<div class="form-group">
|
|
<label style="display:flex;align-items:center;gap:0.5rem;cursor:pointer;">
|
|
<input type="checkbox" name="ping_enabled" {% if not host or host.ping_enabled %}checked{% endif %}>
|
|
Enable ping monitor
|
|
</label>
|
|
</div>
|
|
<div class="form-group">
|
|
<label style="display:flex;align-items:center;gap:0.5rem;cursor:pointer;">
|
|
<input type="checkbox" name="dns_enabled" {% if host and host.dns_enabled %}checked{% endif %}>
|
|
Enable DNS monitor
|
|
</label>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Expected IP (optional — leave blank to accept any)</label>
|
|
<input type="text" name="dns_expected_ip" value="{{ host.dns_expected_ip if host and host.dns_expected_ip else '' }}">
|
|
</div>
|
|
<div style="display:flex;gap:1rem;margin-top:1.5rem;">
|
|
<button type="submit" class="btn">{% if host %}Save{% else %}Add Host{% endif %}</button>
|
|
<a href="/hosts/" class="btn btn-ghost">Cancel</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
{% if host and ansible_sources %}
|
|
<div class="card" style="margin-top:1.5rem;">
|
|
<h3 class="section-title" style="margin-bottom:0.5rem;">Run Ansible playbook against this host</h3>
|
|
<p style="color:var(--text-muted);font-size:0.82rem;margin-bottom:1rem;">
|
|
Runs against an ephemeral one-host inventory for
|
|
<code>{{ host.name }}</code> ({{ host.address or "no address — resolves by name" }}).
|
|
Use a playbook with <code>hosts: all</code>.
|
|
</p>
|
|
<form method="post" action="/hosts/{{ host.id }}/run-playbook">
|
|
<div class="form-group">
|
|
<label>Source</label>
|
|
<select name="source_name" required>
|
|
{% for s in ansible_sources %}<option value="{{ s }}">{{ s }}</option>{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Playbook <span style="color:var(--text-muted);font-weight:normal;">(path within source)</span></label>
|
|
<input type="text" name="playbook_path" placeholder="playbooks/site.yml" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Extra vars <span style="color:var(--text-muted);font-weight:normal;">(optional, one key=value per line)</span></label>
|
|
<textarea name="extra_vars" rows="2"
|
|
style="width:100%;font-family:ui-monospace,monospace;font-size:0.85rem;"></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Tags <span style="color:var(--text-muted);font-weight:normal;">(optional)</span></label>
|
|
<input type="text" name="tags">
|
|
</div>
|
|
<div class="form-group">
|
|
<label style="display:flex;align-items:center;gap:0.5rem;font-weight:normal;">
|
|
<input type="checkbox" name="check"> Dry-run (--check --diff)
|
|
</label>
|
|
</div>
|
|
<button type="submit" class="btn">Run playbook</button>
|
|
</form>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if host %}
|
|
<div class="card" style="margin-top:1.5rem;max-width:560px;margin-left:auto;margin-right:auto;">
|
|
<h3 class="section-title">Ansible Target</h3>
|
|
{% if linked_target %}
|
|
<div style="display:flex;align-items:center;gap:1rem;padding:0.75rem;background:var(--bg-elevated);border-radius:4px;margin-bottom:1rem;">
|
|
<div style="flex:1;">
|
|
<strong>{{ linked_target.name }}</strong>
|
|
<span style="color:var(--text-muted);font-size:0.85rem;margin-left:0.5rem;">{{ linked_target.address }}</span>
|
|
{% if linked_target.groups %}
|
|
<div style="margin-top:0.25rem;">
|
|
{% for grp in linked_target.groups %}
|
|
<span style="font-size:0.78rem;background:var(--bg);border-radius:3px;padding:0.1em 0.4em;margin-right:0.2rem;color:var(--text-muted);">{{ grp.name }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
<a href="/ansible/inventory/targets/{{ linked_target.id }}" class="btn btn-ghost btn-sm">Edit Target</a>
|
|
<form method="post" action="/hosts/{{ host.id }}/ansible-link" style="display:inline;">
|
|
<input type="hidden" name="action" value="unlink">
|
|
<button type="submit" class="btn btn-ghost btn-sm">Unlink</button>
|
|
</form>
|
|
</div>
|
|
{% else %}
|
|
<p style="color:var(--text-muted);font-size:0.9rem;margin-bottom:1rem;">
|
|
No Ansible target linked. Link an existing target or create one from this host.
|
|
</p>
|
|
<div style="display:flex;gap:0.75rem;flex-wrap:wrap;align-items:flex-end;">
|
|
{% if linkable_targets %}
|
|
<form method="post" action="/hosts/{{ host.id }}/ansible-link" style="display:flex;gap:0.5rem;align-items:center;flex:1;">
|
|
<input type="hidden" name="action" value="link">
|
|
<select name="target_id" style="flex:1;">
|
|
{% for tgt in linkable_targets %}
|
|
<option value="{{ tgt.id }}">{{ tgt.name }} ({{ tgt.address }})</option>
|
|
{% endfor %}
|
|
</select>
|
|
<button type="submit" class="btn btn-sm">Link</button>
|
|
</form>
|
|
{% endif %}
|
|
<form method="post" action="/hosts/{{ host.id }}/ansible-link">
|
|
<input type="hidden" name="action" value="create">
|
|
<button type="submit" class="btn btn-sm btn-ghost">Create Target from This Host</button>
|
|
</form>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|