diff --git a/config/lang/de.json b/config/lang/de.json index b3dd2dac549efcd480c39b668442391f4be01fc8..6776db8fe94659334796e08c491422c430565b09 100644 --- a/config/lang/de.json +++ b/config/lang/de.json @@ -131,7 +131,8 @@ "class-project-info-deploy-skip-sync": "SKIP: Synchronisationstyp "%s" wird (noch) nicht unterstützt.", "class-project-info-deploy-start-by-method": "Starte Installation auf Zielhosts", "class-project-info-deploy-start-by-method-skip": "SKIP: es gibt nichts zu tun. Wurde keine Installationsart und/ oder kein Ziel Host definiert.", - "class-project-info-deploy-successful": "Das Deployment wurde erfolgreich abgeschlossen.", + "class-project-info-deploy-successful": "Das Deployment der Phase %s wurde erfolgreich abgeschlossen.", + "class-project-info-deploy-failed": "Das Deployment der Phase %s enthält Fehler.", "class-project-info-accept-overview": "Info: in der Phase "%s" ist installiert:", "class-project-info-accept-version-and-next-phase": "Die aktuelle Version [%s] wird nun in die Queue der Phase [%s] gestellt.", "class-project-info-setup-phaseinfos": "Aktiviere die Phasen des Projektes und gib die URLs der jeweiligen Applikationen an.<br>Der Sysadmin muss zudem die einzelnen Hosts in Puppet konfigurieren - bitte neu zuverwendende Server mit ihm abstimmen.", diff --git a/config/lang/en.json b/config/lang/en.json index 50786dcdf6dac5b1cd520caa090caee0bac65942..fb01122710bc61359e89894d7b8bbcdbcbfe5213 100644 --- a/config/lang/en.json +++ b/config/lang/en.json @@ -132,7 +132,8 @@ "class-project-info-deploy-skip-sync": "SKIP: Synchronisation type "%s" is not supported (yet).", "class-project-info-deploy-start-by-method": "Starting installation to target hosts", "class-project-info-deploy-start-by-method-skip": "SKIP: nothing to do. No method an/ or target host were defined.", - "class-project-info-deploy-successful": "The deployment was finished successfully.", + "class-project-info-deploy-successful": "The deployment of phase %s was finished successfully.", + "class-project-info-deploy-failed": "The deployment of phase %s failed.", "class-project-info-accept-overview": "Info: in the phase "%s" is installed:", "class-project-info-accept-version-and-next-phase": "The current version [%s] will be put to the queue of phase [%s].", "class-project-info-setup-phaseinfos": "Activate the needed phases for your project. Enter the urls of each phase.<br>Fore new hosts: contact the system administrator - he must configure the hosts before the project can be installed there.", diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 054c8af52f74933a92b00e892318c01fcbb6bc1a..954fade36f5ed727aac656d48af84393f8f29ca2 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -2191,12 +2191,7 @@ class project extends base { $sReturn.=t("class-project-info-deploy-start-by-method-skip") . "<br>"; } else { - $sReturn.='<p>' - . 'Plugin: '.$this->oRolloutPlugin->getId().'<br>' - . '</p>' - . '<pre>Config for phase '.$sPhase.' = '.print_r($this->oRolloutPlugin->getConfig($sPhase), 1).'</pre>' - . '<pre>Commands = '.print_r($this->oRolloutPlugin->getDeployCommands($sPhase), 1).'</pre>' - ; + $sReturn.='<p>' . 'Plugin: '.$this->oRolloutPlugin->getId().'</p>'; foreach($this->oRolloutPlugin->getDeployCommands($sPhase) as $sCmd){ $sReturn.=$this->_execAndSend("$sCmd"); @@ -2234,10 +2229,18 @@ class project extends base { $this->_TempFill($sReturn, $aActionList); $sReturn.="<br>"; - $sReturn.=$this->_oHtml->getBox("success", t("class-project-info-deploy-successful")); - $this->_sendMessage(t("class-project-info-deploy-successful")."\nphase: ${sPhase}\n"); - $this->_logaction(t('finished') . " deploy($sPhase, $bIgnoreDeploytimes) " . t("class-project-info-deploy-successful"), __FUNCTION__, "success"); + if (!$this->_iRcAll == 0) { + $sWarnlevel='error'; + $sMessage = sprintf(t('class-project-info-deploy-failed'), $sPhase); + } else { + $sWarnlevel='success'; + $sMessage=sprintf(t("class-project-info-deploy-successful"), $sPhase); + } + $sReturn.=$this->_oHtml->getBox($sWarnlevel, $sMessage); + $this->_sendMessage($sMessage); + $this->_logaction(t('finished') . " deploy($sPhase, $bIgnoreDeploytimes) " . $sMessage, __FUNCTION__, $sWarnlevel); + $this->_TempDelete(); return $sReturn; } @@ -3958,12 +3961,24 @@ class project extends base { // -------------------------------------------------- // Tab for raw data // -------------------------------------------------- + + $sRolloutDebug='<hr>DEBUG:<br>'; + foreach (array_keys($this->getPhases()) as $sPhase) { + if ($this->isActivePhase($sPhase)){ + $sRolloutDebug.='<strong>'.$sPhase.'</strong>' + . '<pre>Config = '.print_r($this->oRolloutPlugin->getConfig($sPhase), 1).'</pre>' + . '<pre>Commands = '.print_r($this->oRolloutPlugin->getDeployCommands($sPhase), 1).'</pre>' + ; + } + } + $aForms["setup"]["form"]['input' . $i++] = array( 'type' => 'markup', 'value' => '</div>' . '<div class="tab-pane" id="tab6">' . '<br><pre>'.print_r($this->_aPrjConfig, 1).'</pre>' + . $sRolloutDebug . '</div>' . '</div>' diff --git a/public_html/deployment/plugins/rollout/awx/rollout_awx.php b/public_html/deployment/plugins/rollout/awx/rollout_awx.php index 7ec6f2dcbbdccc55fb6aaa1c42afff493c27894c..276cca0a4afe122d46175dcb707595fad07066dc 100644 --- a/public_html/deployment/plugins/rollout/awx/rollout_awx.php +++ b/public_html/deployment/plugins/rollout/awx/rollout_awx.php @@ -17,7 +17,15 @@ class rollout_awx extends rollout_base { // no specific checks needed ... always true return true; } - + + /** + * check access to a deploy target + */ + public function checkConnectionToTarget() { + // do nothing ... always true + return true; + } + /** * make an http get request and return the response body * it is called by _makeRequest @@ -71,8 +79,6 @@ class rollout_awx extends rollout_base { return $aReturn; } - - /** * get AWX inventories and return them as array for select box * [id] => array('value' => [ID], 'label' => [NAME] [ID]) @@ -129,13 +135,6 @@ class rollout_awx extends rollout_base { return $aReturn; } - /** - * check access to a deploy target - */ - public function checkConnectionToTarget() { - // do nothing ... always true - return true; - } /** * get array with commands to execute to deploy a package @@ -146,17 +145,31 @@ class rollout_awx extends rollout_base { public function getDeployCommands($sPhase){ $aReturn=array(); $aConfig=$this->getConfig($sPhase); + + // ----- Checks: + $sCmdChecks=''; + if($aConfig['extravars']){ + $aTmp=json_decode($aConfig['extravars']); + if (!$aTmp || !count($aTmp) ){ + $sCmdChecks.='echo "ERROR: Value in extravars has wrong Syntax - this is no JSON: '.$aConfig['extravars'].'"; exit 1; '; + } + $aConfig['extravars']=json_encode($aTmp); + } + if(!(int)$aConfig['inventory']){ - $aReturn[]='echo "ERROR: no inventory was given."; exit 1'; + $sCmdChecks.='echo "ERROR: no inventory was given."; exit 1; '; } - $sJson='{ - "inventory": "'.$aConfig['inventory'].'", - "limit": "'.$aConfig['limit'].'", - "job_tags": "'.$aConfig['tags'].'", - "extra_vars": '.$aConfig['extravars'].' - }'; + + // ----- Send variables having values only + $aBodyvars=array(); + foreach(['inventory'=>'inventory', 'limit'=>'limit', 'job_tags'=>'tags', 'extra_vars'=>'extravars'] as $sParam=>$sVarkey){ + if ($aConfig[$sVarkey]) { + $aBodyvars[$sParam]=$aConfig[$sVarkey]; + } + } + $sAuth=($aConfig['user'] ? '--user '.$aConfig['user'].':'.$aConfig['password'] : ''); - $aReturn[]="curl -f -k -H 'Content-Type: application/json' -XPOST -d '".$sJson."' $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; }