Debug / fix template_id isse
This commit is contained in:
@@ -171,6 +171,7 @@ abstract class BaseController extends Controller
|
||||
$result = "Found token: $token";
|
||||
# Print response.
|
||||
log_message('critical', "***** ***** Provision LOGIN TOKEN :: " . $token);
|
||||
log_message('critical', $result);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
@@ -196,6 +197,7 @@ abstract class BaseController extends Controller
|
||||
$PROJECT_ID = $_ENV['ANSIBLE_AUTOMATION_PROJECT_ID'];
|
||||
|
||||
try {
|
||||
$streamVerboseHandle = fopen('php://temp', 'w+');
|
||||
|
||||
$url = $base_url . $_ENV['ANSIBLE_TASK_URL'] . $PROJECT_ID . "/tasks";
|
||||
log_message('critical', "***** ***** Provision TASK CREATE CALL URL:: " . $url);
|
||||
@@ -205,23 +207,35 @@ abstract class BaseController extends Controller
|
||||
// $payload = json_encode( array( "template_id"=> 1, "debug" => false, "dry_run" => false, "playbook" => "first-playbook.yml", "environment" => "{}" ) );
|
||||
// Set method to POST
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
|
||||
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_STDERR, $streamVerboseHandle);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$res = curl_exec($ch);
|
||||
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
// 4. Check for errors during the execution
|
||||
if (curl_errno($ch)) {
|
||||
$error_message = 'cURL error: ' . curl_error($ch);
|
||||
if ($res === FALSE || $httpcode != 200 || curl_errno($ch)) {
|
||||
$error_message = 'HTTP code: '.$httpcode.', cURL error: ' . curl_error($ch);
|
||||
log_message('critical', "***** ***** Provision LAUNCHED ERROR :: " . $error_message);
|
||||
log_message('critical', $res);
|
||||
log_message('critical', $payload);
|
||||
}
|
||||
|
||||
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
// Rewind the verbose stream and get its contents
|
||||
rewind($streamVerboseHandle);
|
||||
$verboseLog = stream_get_contents($streamVerboseHandle);
|
||||
|
||||
//$result = 'Launch Ansible Tasks with HTTP Status::code ' . $httpcode;
|
||||
log_message('critical', "***** ***** Provision LAUNCHED :: ansibleProvision(HTTP Status::code) " . $httpcode);
|
||||
|
||||
curl_close($ch);
|
||||
fclose($streamVerboseHandle);
|
||||
|
||||
log_message('critical','>>>>>>'.$verboseLog);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
log_message('critical', "***** ***** Provision TASK CREATION FAILED :: " . $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ class Provision extends BaseController
|
||||
$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");
|
||||
$params = [
|
||||
"template_id" => $_ENV['ANSIBLE_TEMPLATE_ID'],
|
||||
"template_id" => (int)$_ENV['ANSIBLE_TEMPLATE_ID'],
|
||||
"debug" => false,
|
||||
"dry_run" => false,
|
||||
"playbook" => $playbook,
|
||||
@@ -743,7 +743,7 @@ class Provision extends BaseController
|
||||
$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");
|
||||
$params = [
|
||||
"template_id" => $_ENV['ANSIBLE_TEMPLATE_ID'],
|
||||
"template_id" => (int)$_ENV['ANSIBLE_TEMPLATE_ID'],
|
||||
"debug" => false,
|
||||
"dry_run" => false,
|
||||
"playbook" => $playbook,
|
||||
|
||||
Reference in New Issue
Block a user