<?php /** * * Rollout plugin - awx * * Run an Https POST request to AWX * * @author axel */ class rollout_awx extends rollout_base { /** * check requirements if the plugin could work */ public function checkRequirements() { // no specific checks needed ... always true return true; } /** * check access to a deploy target */ public function checkConnectionToTarget() { // do nothing ... always true return true; } public function getDeployCommands($sPhase){ $aReturn=array(); $aConfig=$this->getConfig($sPhase); if(!(int)$aConfig['inventory']){ $aReturn[]='echo "ERROR: no inventory was given."; exit 1'; } $sJson='{ "inventory": "'.$aConfig['inventory'].'", "limit": "'.$aConfig['limit'].'", "job_tags": "'.$aConfig['tags'].'", "extra_vars": '.$aConfig['extravars'].' }'; $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/"; return $aReturn; } }