feat(ansible): host edit page Ansible target link/create/unlink section

This commit is contained in:
2026-06-05 18:51:33 -04:00
parent 37d9ca8a8a
commit dd0acaf623
2 changed files with 126 additions and 4 deletions
+47
View File
@@ -88,4 +88,51 @@
</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 %}