Skip to content
Snippets Groups Projects
Commit 2349586a authored by hahn's avatar hahn
Browse files

- add ssh host key

- fixed: hardcoded exec of puppet agent --version
parent 38f3560b
No related branches found
No related tags found
No related merge requests found
...@@ -13,3 +13,4 @@ nbproject ...@@ -13,3 +13,4 @@ nbproject
/config/projects/imlplayer.json.ok /config/projects/imlplayer.json.ok
/config/projects/doccom.json.ok /config/projects/doccom.json.ok
/config/projects/ci.json /config/projects/ci.json
/database/logs.db
\ No newline at end of file
...@@ -24,11 +24,11 @@ $aConfig = array( ...@@ -24,11 +24,11 @@ $aConfig = array(
// %s is name of the server (2x) // %s is name of the server (2x)
'addkeycommand' => '/usr/bin/ssh-keygen -R %s; /usr/bin/ssh-keyscan -t rsa %s >> /home/www-data/.ssh/known_hosts', 'addkeycommand' => '/usr/bin/ssh-keygen -R %s; /usr/bin/ssh-keyscan -t rsa %s >> /home/www-data/.ssh/known_hosts',
// command to verify if puppet host is correct
'testcommand' => 'sudo puppet --version', 'testcommand' => 'sudo puppet --version',
// puppet agent liefert 0 oder 2 zurueck, wenn OK // puppet agent liefert 0 oder 2 zurueck, wenn OK
// http://docs.puppetlabs.com/references/3.4.0/man/apply.html // http://docs.puppetlabs.com/references/3.4.0/man/apply.html
// 'command'=>'sudo puppet agent -t | fgrep -i Deploy',
// 'command'=>'sudo puppet agent -t --detailed-exitcodes ; echo rc=$? | egrep -v "^rc=(0|2)$" ; typeset -i rc=(1-$?); exit $rc',
'command' => 'sudo puppet agent -t --detailed-exitcodes ; rc=$?; if [ $rc -eq 2 ]; then rc=0; fi ; exit $rc', 'command' => 'sudo puppet agent -t --detailed-exitcodes ; rc=$?; if [ $rc -eq 2 ]; then rc=0; fi ; exit $rc',
), ),
'phases' => array( 'phases' => array(
......
...@@ -1474,7 +1474,7 @@ class project { ...@@ -1474,7 +1474,7 @@ class project {
$sCmd = 'ssh ' . $this->_aConfig["installPackages"]["user"] $sCmd = 'ssh ' . $this->_aConfig["installPackages"]["user"]
. '@' . $this->_aPrjConfig["phases"][$sPhase]["puppethost"] . '@' . $this->_aPrjConfig["phases"][$sPhase]["puppethost"]
. ' ' . $this->_aConfig["installPackages"]["command"]; . ' ' . $this->_aConfig["installPackages"]["command"];
// $sReturn.=$this->_execAndSend("ssh imldeployment@" . $this->_aPrjConfig["phases"][$sPhase]["puppethost"] . " sudo puppet agent -t | fgrep -i Deploy"); // | fgrep -i Deploy
$sReturn.=$this->_execAndSend("$sCmd"); $sReturn.=$this->_execAndSend("$sCmd");
} else { } else {
$sReturn.=t("class-project-info-deploy-start-puppet-skip") . "<br>"; $sReturn.=t("class-project-info-deploy-start-puppet-skip") . "<br>";
...@@ -1554,15 +1554,6 @@ class project { ...@@ -1554,15 +1554,6 @@ class project {
$this->_logaction(t('finished')." saveConfig(...)", __FUNCTION__, "success"); $this->_logaction(t('finished')." saveConfig(...)", __FUNCTION__, "success");
$this->setProjectById($sId); $this->setProjectById($sId);
foreach (array_keys($aData["phases"]) as $sPhase){
if ($aData["phases"][$sPhase]["puppethost"]) {
$sServer=$aData["phases"][$sPhase]["puppethost"];
$sCmd="/usr/bin/ssh-keygen -R $sServer; /usr/bin/ssh-keyscan -t rsa $sServer >> $sKnownhosts";
echo $sCmd."<br>";
exec($sCmd);
}
}
return $bReturn; return $bReturn;
} }
...@@ -2341,6 +2332,7 @@ class project { ...@@ -2341,6 +2332,7 @@ class project {
foreach (array_keys($this->getPhases()) as $sPhase) { foreach (array_keys($this->getPhases()) as $sPhase) {
$sUrl = array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["url"] : ""; $sUrl = array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["url"] : "";
// $aTmp=parse_url($sUrl); $sPuppethost=$aTmp["host"];
$sPuppethost = array_key_exists("puppethost", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["puppethost"] : ""; $sPuppethost = array_key_exists("puppethost", $this->_aPrjConfig["phases"][$sPhase]) ? $this->_aPrjConfig["phases"][$sPhase]["puppethost"] : "";
$aForms["setup"]["form"]['input' . $i++] = array( $aForms["setup"]["form"]['input' . $i++] = array(
'type' => 'markup', 'type' => 'markup',
...@@ -2378,7 +2370,6 @@ class project { ...@@ -2378,7 +2370,6 @@ class project {
. '@' . $sPuppethost . '@' . $sPuppethost
. ' ' . $this->_aConfig["installPackages"]["testcommand"]; . ' ' . $this->_aConfig["installPackages"]["testcommand"];
$sOut = shell_exec($sCmd2); $sOut = shell_exec($sCmd2);
// Check auf Versionsnummer - mehr als n Zeichen ist mutmasslich eine Fehlermeldung // Check auf Versionsnummer - mehr als n Zeichen ist mutmasslich eine Fehlermeldung
if (strlen($sOut) > 7) { if (strlen($sOut) > 7) {
$sMessages.=$this->getBox("error", sprintf(t("class-project-error-setup-sudo-pupet-agent-failed"), $sPhase, $sCmd, $sOut)); $sMessages.=$this->getBox("error", sprintf(t("class-project-error-setup-sudo-pupet-agent-failed"), $sPhase, $sCmd, $sOut));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment