Initial import from running container + overrides

This commit is contained in:
root committed 2025-09-17 12:05:52 +02:00
commit d9864f0cfd
27 files changed
+891

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
{% extends "base.html" %}
{% block content %}
<div class="card">
<h2 style="margin-top:0">Administration — Upload de playbooks</h2>
<form method="post" enctype="multipart/form-data">
<div class="grid">
<div>
<label>Domaine</label>
<input type="text" name="domain" placeholder="ex: ipam, discovery, network" required>
</div>
<div>
{% if require_token %}
<label>Token Administrateur</label>
<input type="password" name="token" placeholder="ADMIN_TOKEN" required>
</div>
{% endif %}
</div>
<div style="margin-top:10px">
<input type="file" name="file" accept=".yml,.yaml" required>
</div>
<div class="row" style="margin-top:12px">
<button type="submit">Charger le playbook</button>
<a href="{{ url_for('user_home') }}" class="badge">Aller à la vue Utilisateurs</a>
</div>
<div class="small" style="margin-top:8px">Seuls les fichiers .yml/.yaml sont acceptés. Le fichier est stocké par domaine et visible dans la vue Utilisateurs.</div>
</form>
</div>
<div class="card">
<h3 style="margin-top:0">Playbooks disponibles</h3>
{% if grouped %}
{% for domain, items in grouped.items() %}
<h4>{{ domain }} <span class="badge">{{ items|length }} playbook(s)</span></h4>
<table class="table">
<tr><th>Nom</th><th>Taille</th><th>Modifié</th><th>SHA256</th><th>Actions</th></tr>
{% for pb in items %}
<tr>
<td>{{ pb.name }}</td>
<td>{{ pb.size_h }}</td>
<td>{{ pb.mtime_h }}</td>
<td class="small">{{ pb.sha256[:16] }}…</td>
<td>
<a class="badge" href="{{ url_for('user_run', domain=domain, name=pb.name) }}">Ouvrir</a>
</td>
</tr>
{% endfor %}
</table>
<hr/>
{% endfor %}
{% else %}
<div class="small">Aucun playbook pour le moment.</div>
{% endif %}
</div>
{% endblock %}
+31
View File
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>{{ title or "IHM Playbooks" }}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='app.css') }}">
</head>
<body>
<div class="header">
<h1>🧰 IHM Playbooks</h1>
<div class="nav">
<a href="{{ url_for('user_home') }}">Utilisateurs</a>
<a href="{{ url_for('admin_home') }}">Administration</a>
</div>
</div>
<div class="container">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for cat,msg in messages %}
<div class="card" style="border-left:6px solid {% if cat=='error' %}#F87171{% elif cat=='ok' %}#6EE7B7{% else %}#60A5FA{% endif %};">
{{ msg }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
<div class="footer small">POC — Ephaitek • Flask</div>
</div>
</body>
</html>
+55
View File
@@ -0,0 +1,55 @@
{% extends "base.html" %}
{% block content %}
<div class="card">
<h2 style="margin-top:0">Lancer un playbook</h2>
<div class="row">
<div class="badge">Domaine: {{ domain }}</div>
<div class="badge">Playbook: {{ name }}</div>
<div class="badge">Chemin: {{ rel_path }}</div>
</div>
<form id="runForm" class="grid" style="margin-top:10px">
<div>
<label>Extra Vars (YAML or key1=val1 key2=val2)</label>
<textarea name="extra_vars" rows="4" placeholder='{"netbox_url":"...", "netbox_token":"..."}'></textarea>
</div>
<div>
<label>Vérification (dry-run)</label>
<select name="check">
<option value="no" selected>Non</option>
<option value="yes">Oui (ansible-playbook --check)</option>
</select>
<label style="margin-top:8px;display:block">Verbosity</label>
<select name="vvv">
<option value="">-v (léger)</option>
<option value="-vv">-vv</option>
<option value="-vvv" selected>-vvv</option>
</select>
</div>
</form>
<div class="row" style="margin-top:10px">
<button id="btnRun">Exécuter</button>
<a class="badge" href="{{ url_for('user_home') }}">Retour</a>
</div>
</div>
<div class="card">
<h3 style="margin-top:0">Sortie</h3>
<pre id="log" class="log"></pre>
</div>
<script>
const logEl = document.getElementById('log');
const btn = document.getElementById('btnRun');
btn.addEventListener('click', async ()=>{
logEl.textContent = 'Démarrage…\n';
const form = document.getElementById('runForm');
const data = new FormData(form);
const res = await fetch('{{ url_for("api_run_start", domain=domain, name=name) }}', {method:"POST", body:data});
if(!res.ok){ logEl.textContent += 'Erreur démarrage ('+res.status+')'; return; }
const { job_id } = await res.json();
const src = new EventSource('{{ url_for("api_stream", job_id="") }}'+job_id);
src.onmessage = (e)=>{ logEl.textContent += e.data + "\n"; logEl.scrollTop = logEl.scrollHeight; };
src.onerror = ()=>{ src.close(); logEl.textContent += "\n[Flux terminé]"; };
});
</script>
{% endblock %}
+36
View File
@@ -0,0 +1,36 @@
{% extends "base.html" %}
{% block content %}
<div class="card">
<h2 style="margin-top:0">Catalogue de playbooks</h2>
<form method="get" class="row">
<input type="text" name="q" placeholder="Rechercher…" value="{{ q or '' }}" style="flex:1">
<select name="sort">
<option value="mtime" {% if sort=='mtime' %}selected{% endif %}>Tri: récents</option>
<option value="name" {% if sort=='name' %}selected{% endif %}>Tri: nom</option>
<option value="size" {% if sort=='size' %}selected{% endif %}>Tri: taille</option>
</select>
<button type="submit" class="secondary">Appliquer</button>
</form>
</div>
{% for domain, items in grouped.items() %}
<div class="card">
<h3 style="margin-top:0">{{ domain }} <span class="badge">{{ items|length }} playbook(s)</span></h3>
<table class="table">
<tr><th>Nom</th><th>Taille</th><th>Modifié</th><th></th></tr>
{% for pb in items %}
<tr>
<td>{{ pb.name }}</td><td>{{ pb.size_h }}</td><td>{{ pb.mtime_h }}</td>
<td style="text-align:right">
<a class="badge" href="{{ url_for('user_run', domain=domain, name=pb.name) }}">Lancer</a>
</td>
</tr>
{% endfor %}
</table>
</div>
{% endfor %}
{% if not grouped %}
<div class="card small">Aucun playbook disponible. Demandez à l’admin d’en charger un via la page d’administration.</div>
{% endif %}
{% endblock %}