Skip to content
Snippets Groups Projects
Commit 1c77e7bd authored by hahn's avatar hahn
Browse files

task #4637 - awx: put echo with error and curl into single command

parent 1d962ffe
No related branches found
No related tags found
1 merge request!12AWX - handling leerer AWX felder
...@@ -147,16 +147,17 @@ class rollout_awx extends rollout_base { ...@@ -147,16 +147,17 @@ class rollout_awx extends rollout_base {
$aConfig=$this->getConfig($sPhase); $aConfig=$this->getConfig($sPhase);
// ----- Checks: // ----- Checks:
$sCmdChecks='';
if($aConfig['extravars']){ if($aConfig['extravars']){
$aTmp=json_decode($aConfig['extravars']); $aTmp=json_decode($aConfig['extravars']);
if (!$aTmp || !count($aTmp) ){ if (!$aTmp || !count($aTmp) ){
$aReturn[]='echo "ERROR: Value in extravars has wrong Syntax - this is no JSON: '.$aConfig['extravars'].'"'; $sCmdChecks.='echo "ERROR: Value in extravars has wrong Syntax - this is no JSON: '.$aConfig['extravars'].'"; exit 1; ';
} }
$aConfig['extravars']=json_encode($aTmp); $aConfig['extravars']=json_encode($aTmp);
} }
if(!(int)$aConfig['inventory']){ if(!(int)$aConfig['inventory']){
$aReturn[]='echo "ERROR: no inventory was given."; exit 1'; $sCmdChecks.='echo "ERROR: no inventory was given."; exit 1; ';
} }
// ----- Send variables having values only // ----- Send variables having values only
...@@ -168,7 +169,7 @@ class rollout_awx extends rollout_base { ...@@ -168,7 +169,7 @@ class rollout_awx extends rollout_base {
} }
$sAuth=($aConfig['user'] ? '--user '.$aConfig['user'].':'.$aConfig['password'] : ''); $sAuth=($aConfig['user'] ? '--user '.$aConfig['user'].':'.$aConfig['password'] : '');
$aReturn[]="curl -f -k -H 'Content-Type: application/json' -XPOST -d '". json_encode($aBodyvars, JSON_PRETTY_PRINT)."' $sAuth ".$aConfig['url']."/job_templates/".$aConfig['jobtemplate']."/launch/"; $aReturn[]=$sCmdChecks . "curl -f -k -H 'Content-Type: application/json' -XPOST -d '". json_encode($aBodyvars, JSON_PRETTY_PRINT)."' $sAuth ".$aConfig['url']."/job_templates/".$aConfig['jobtemplate']."/launch/";
return $aReturn; return $aReturn;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment