Commit 535aec59cd2f771f1c7d5d07d8adc7e0528668cb
1 parent
2bbeba39
Test de lancement d'Ansible depuis le site
Showing
3 changed files
with
21 additions
and
21 deletions
Show diff stats
site/reception.php
@@ -46,31 +46,31 @@ if(isset($_POST['sensor'])) | @@ -46,31 +46,31 @@ if(isset($_POST['sensor'])) | ||
46 | 46 | ||
47 | if(!$err) | 47 | if(!$err) |
48 | { | 48 | { |
49 | - if(file_put_contents('upload/inventaire.ini', $ini)!=NULL) | ||
50 | - { | ||
51 | - $upload = load($_FILES['fichier']['tmp_name'], $_FILES['fichier']['name']); | ||
52 | - if($upload) | 49 | + file_put_contents('upload/inventaire.ini', $ini) |
50 | + $upload = load($_FILES['fichier']['tmp_name'], $_FILES['fichier']['name']); | ||
51 | + if($upload) | ||
52 | + { | ||
53 | + $message = "Upload du fichier réussi !"; | ||
54 | + $color = "alert-success"; | ||
55 | + $cmd = "ansible-playbook ../Ansible/taskPing.yml -i upload/inventaire.ini"; | ||
56 | + $ansible = shell_exec($cmd); | ||
57 | + if($ansible==NULL) | ||
53 | { | 58 | { |
54 | - $message = "Upload du fichier réussi !"; | ||
55 | - $color = "alert-success"; | ||
56 | - $cmd = "ansible-playbook ../Ansible/taskPing.yml -i upload/inventaire.ini"; | ||
57 | - if(shell_exec($cmd)==NULL) | ||
58 | - { | ||
59 | - // gestion de l'erreur | ||
60 | - $message = $message." Ansible est lancé !"; | ||
61 | - } | ||
62 | - else | ||
63 | - { | ||
64 | - $message = $message." Echec du lancement d'Ansible !"; | ||
65 | - $color = "alert-danger"; | ||
66 | - } | 59 | + // Gestion de l'erreur |
60 | + $message = $message." Echec du lancement d'Ansible !"; | ||
61 | + $color = "alert-danger"; | ||
67 | } | 62 | } |
68 | else | 63 | else |
69 | { | 64 | { |
70 | - $message = "Erreur lors du transfert du fichier..."; | ||
71 | - $color = "alert-danger"; | 65 | + // Réussite |
66 | + $message = $message." Ansible est lancé !"." Réponse Ansible : ".$ansible; | ||
72 | } | 67 | } |
73 | } | 68 | } |
69 | + else | ||
70 | + { | ||
71 | + $message = "Erreur lors du transfert du fichier..."; | ||
72 | + $color = "alert-danger"; | ||
73 | + } | ||
74 | } | 74 | } |
75 | else | 75 | else |
76 | { | 76 | { |
site/reponse.php
1 | -<div class="row"> | 1 | +<div class="row" style="margin-bottom:20px; margin-top:60px;"> |
2 | <div class="col-4 col-md-4 offset-4 offset-md-4"> | 2 | <div class="col-4 col-md-4 offset-4 offset-md-4"> |
3 | <br/> | 3 | <br/> |
4 | <div class="alert <?php echo $color;?>" role="alert"> | 4 | <div class="alert <?php echo $color;?>" role="alert"> |
site/tableau.php
1 | <div class="row"> | 1 | <div class="row"> |
2 | <div class="col-4 col-md-4 offset-4 offset-md-4"> | 2 | <div class="col-4 col-md-4 offset-4 offset-md-4"> |
3 | - <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-info-circle"></i> Informations complémentaires</h1> | 3 | + <h1 style="margin-bottom:20px; margin-top:20px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-info-circle"></i> Informations complémentaires</h1> |
4 | <table class="table table-striped table-bordered"> | 4 | <table class="table table-striped table-bordered"> |
5 | <tbody> | 5 | <tbody> |
6 | <tr> | 6 | <tr> |