2.6 KiB · text History d69022d
{% extends "base.html" %}
{% block title %}devendra · hosts{% endblock %}
{% block content %}
  <h1>Hosts</h1>
  {% if hosts %}
  <table>
    <thead>
      <tr><th>Host</th><th>Last report</th><th>Generation</th><th>Changes</th><th>When</th></tr>
    </thead>
    <tbody>
      {% for h in hosts %}
      <tr>
        <td>
          <a href="/hosts/{{ h.id }}">{{ h.id }}</a>
          {% if h.has_adoption %}<a href="/hosts/{{ h.id }}/adopt" class="pill changed" style="text-decoration:none">adopt&nbsp;pending</a>{% endif %}
        </td>
        <td>
          {% if h.status %}
            <span class="pill {{ h.status.result }}">{{ h.status.result }}</span>
          {% else %}
            <span class="pill none">no report</span>
          {% endif %}
        </td>
        <td>{% if h.status %}{{ h.status.generation }}{% else %}—{% endif %}</td>
        <td>
          {% if h.status %}
            {{ h.status.changed }} changed{% if h.status.failed %}, <span class="pill failed">{{ h.status.failed }} failed</span>{% endif %}
          {% else %}—{% endif %}
        </td>
        <td class="muted">{% if h.status %}{{ h.status.age }}{% else %}—{% endif %}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
  {% else %}
  <div class="card muted">
    No hosts yet. Create a TOML file under <code>config/hosts/&lt;id&gt;.toml</code>, or add one below.
  </div>
  {% endif %}

  {% if unmanaged %}
  <h2>Pending adoptions</h2>
  <p class="muted">Agents proposing files for hosts that aren't managed yet. Review to onboard them.</p>
  <ul>
    {% for id in unmanaged %}
      <li><a href="/hosts/{{ id }}/adopt">{{ id }}</a> <span class="pill changed">adopt pending</span></li>
    {% endfor %}
  </ul>
  {% endif %}

  <h2>New host</h2>
  <form method="post" action="/hosts" class="card">
    <p><label>Host id<br><input type="text" name="id" placeholder="web-01" required></label></p>

    <p>Include fragments</p>
    {% if fragments %}
      <div style="display:flex; flex-direction:column; gap:.3rem; margin-bottom:1rem">
        {% for f in fragments %}
          <label><input type="checkbox" name="fragments" value="{{ f }}"> <code>{{ f }}</code></label>
        {% endfor %}
      </div>
    {% else %}
      <p class="muted">No fragments yet — <a href="/fragments">create one</a> to reuse it here.</p>
    {% endif %}

    <p><label>Additional config (optional TOML)<br>
      <textarea name="extra" spellcheck="false" placeholder="# extra [[directories]] / [[files]] / [[services]] for this host"></textarea>
    </label></p>
    <button type="submit">Create</button>
  </form>
{% endblock %}