Refonte
parent
8ea55ac5e2
commit
aac485401b
Binary file not shown.
20
app.py
20
app.py
|
@ -3,22 +3,11 @@ import os
|
|||
from flask import Flask, render_template, request, redirect, url_for
|
||||
from flask_socketio import SocketIO
|
||||
|
||||
from config import *
|
||||
|
||||
app = Flask(__name__)
|
||||
socketio = SocketIO(app)
|
||||
|
||||
FILE_PATH = '/data/interface/fichier.txt'
|
||||
|
||||
class path:
|
||||
ansible_scripts = '/data/Ansible-Playbook/'
|
||||
default_hosts = '/data/Ansible-Playbook/hosts'
|
||||
binary = '/usr/bin/ansible-playbook '
|
||||
|
||||
class flask_config:
|
||||
port=8000
|
||||
host='0.0.0.0'
|
||||
thread=True
|
||||
debug=False
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
playbooks=[]
|
||||
|
@ -33,19 +22,16 @@ def edit():
|
|||
FILE_PATH = path.ansible_scripts+request.form['file_edit']
|
||||
with open(FILE_PATH, 'r') as file:
|
||||
file_content = file.read()
|
||||
return render_template('edit_file.html', file_content=file_content, filepath=FILE_PATH)
|
||||
return render_template('edit_file.html', file_content=file_content, filepath=FILE_PATH,file_name=request.form['file_edit'])
|
||||
|
||||
@app.route('/edit_file', methods=['POST'])
|
||||
def edit_file():
|
||||
new_content = request.form.get('file_content')
|
||||
FILE_PATH = request.form.get('file_path')
|
||||
print("edit "+FILE_PATH)
|
||||
|
||||
with open(FILE_PATH, 'w') as file:
|
||||
file.write(new_content)
|
||||
return redirect(url_for('index'))
|
||||
|
||||
|
||||
@app.route('/run')
|
||||
def run():
|
||||
return render_template('run.html')
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
'''
|
||||
ansible_scripts : location of the playbooks
|
||||
default_hosts: default hosts file path
|
||||
binary : ansible binary path (use "whereis ansible-playbook" to find it)
|
||||
'''
|
||||
|
||||
class path:
|
||||
ansible_scripts = '/data/Ansible-Playbook/'
|
||||
default_hosts = '/data/Ansible-Playbook/hosts'
|
||||
binary = '/usr/bin/ansible-playbook '
|
||||
|
||||
class flask_config:
|
||||
port=8000
|
||||
host='0.0.0.0'
|
||||
thread=True
|
||||
debug=False
|
||||
|
|
@ -6,3 +6,7 @@
|
|||
padding-top: 10px;
|
||||
border-color:#ccc;
|
||||
}
|
||||
.notes {
|
||||
font-style: italic;
|
||||
font-size: xs-small;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
<link href="{{url_for('static', filename = 'style.css')}}" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<title>Ansinterface</title>
|
||||
<center><h1 class="display-6">Ansinterface</h1></center>
|
||||
<div class="container">
|
||||
<br><br>
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
<script>
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
<a href="/">< Back</a>
|
||||
<br>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Editing <code>{{ file_name }}</code>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="{{ url_for('edit_file') }}">
|
||||
<textarea id="code" name="file_content" class="form-control numbered">{{ file_content }}</textarea>
|
||||
<textarea id="code" name="file_content" class="form-control numbered">{{ file_content }}</textarea><br>
|
||||
<input type="hidden" id="file_path" name="file_path" value="{{ filepath }}">
|
||||
<a href="/" class="btn btn-info">Back</a>
|
||||
<button type="submit" value="Save Changes" class="btn btn-info" >Save</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,18 +7,30 @@
|
|||
<div class="card-body">
|
||||
<form id="ansibleForm">
|
||||
|
||||
<label for="playbook">Playbook <span style="color:red">★</span></label>
|
||||
<label for="playbook">Playbook <sup style="color:red">★</sup></label>
|
||||
<select id="playbook" class="form-control" name="playbook" placeholder="Profile" required>
|
||||
{%for file in list %}
|
||||
<option value={{ file }}>{{ file }}</option>
|
||||
{%endfor%}
|
||||
</select>
|
||||
<label for="hosts">Hosts:</label>
|
||||
<!-- -->
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<label for="hosts">Hosts</label>
|
||||
<input type="text" name="hosts" class="form-control" placeholder="/path/to/inventory">
|
||||
<div class="notes">If empty will use default settings.</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label for="argument">Arguments</label>
|
||||
<input type="text" name="argument" class="form-control" placeholder="-e "><br>
|
||||
<input type="text" name="argument" class="form-control" placeholder="-e ">
|
||||
</div>
|
||||
<div class="col">
|
||||
|
||||
<label for="limitation">Limitation</label>
|
||||
<input type="text" name="limitation" class="form-control" placeholder="-l "><br>
|
||||
<input type="text" name="limitation" class="form-control" placeholder="-l ">
|
||||
<div class="notes">Separate your servers with coma (example: localhost,server1...).</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button type="button" class="btn btn-info" onclick="submitForm()">Run</button>
|
||||
</form>
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
<a href="/">< Back</a>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Command output
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="output" class="numbered"></div>
|
||||
<br>
|
||||
<a href="/" class="btn btn-info">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue