This commit is contained in:
CHIEFSOFT\ameye
2025-01-25 19:46:23 -05:00
parent 9ea4da7c6d
commit 7aef227c11
2 changed files with 33 additions and 1 deletions
+3 -1
View File
@@ -8,5 +8,7 @@ use CodeIgniter\Router\RouteCollection;
$routes->get('/', 'Home::index');
$routes->get('/provision/prepare', 'Provision::prepareProvision');
$routes->get('/provision/update', 'Provision::updateProvision');
$routes->get('/provision/update', 'Provision::updateProvision');
$routes->get('/provision/release', 'Provision::releaseProvision');
$routes->get('/provision/target', 'Provision::directProvision');
+30
View File
@@ -288,4 +288,34 @@ class Provision extends BaseController
return 0;
}
public function directProvision(){
$mysql = "SELECT id AS plan_id, uid, provision_id, play_file from provision_plans ORDER BY updated ASC LIMIT 1 ";
$query = $this->db->query($mysql);
$provision_list = $query->getResult();
foreach ($provision_list as $pr) {
$playFile = $pr->play_file;
$planId = $pr->plan_id;
$provisionId = $pr->provision_id;
$this->db->query("UPDATE provision_plans SET updated = now() WHERE id = $planId");
$this->db->query("UPDATE members_products SET p_file = p_file + 1 WHERE id = $provisionId");
//$this->runAnsibleShell($playFile);
try{
log_message('critical', "***** ***** Provision :: runAnsibleShell($playFile) ");
$shellCommand ="ansible-playbook --vault-password-file /var/www/html/ANSIBLE/secrets.pass --key-file ~/.ssh/ansible_worker -i /var/www/html/ANSIBLE/inventory /var/www/html/ANSIBLE/$playFile";
log_message('critical', $shellCommand);
$output = shell_exec($shellCommand );
log_message('critical', "***** ***** Provision :: runAnsibleShell(output) AFTER SHELL RUN ".$output);
} catch ( \Exception $e){
log_message('critical', "***** ***** Provision Error:: runAnsibleShell() ".$e->getMessage());
}
}
return 0;
}
}