Package: praekelt.recipe.deploy
praekelt.recipe.deployBuildout recipe making versioned remote deploys trivial.Creates abin/script with which you can easily deploy buildouts to remote servers. UsesFabricto communicate and run commands on remote servers.NOTE: This recipe is under active development and has not been fully tested in a production environment. Use at your own risk.The deploy process proceeds as follows:The remote host as specified inhostis accessed.A new release path structure is created using this pattern:<root_path>/releases/<release_timestamp>.The git repo as specified ingit_urlis cloned.The newly cloned repo’s branch is switched to the branch as specified ingit_branch. Ifgit_branchis not specified no switch occurs.The repo is switched to the latest tag for the active branch ifdeploy_latest_tagis specified asTrue. Ifdeploy_latest_tagis not specified deploy will be performed from last commit of the active branch.A Puppet manifest as specified inpuppet_manifestis applied if provided.Shared resources as specified inshared_resourcesare copied from the current release(if present) to the newly created release.The Buildout’sboostrap.pyis run using the python executable as specified inpython_execand a Buildout configuration file as specified inconf_file.pythonis used by default ifpython_execis not specified,buildout.cfgis used by default ifconf_fileis not specified.The Buildout is run using a Buildout configuration file as specified inconf_file.buildout.cfgis used by default ifconf_fileis not specified.The<root_path>/currentsymlink is updated to point to newly created release.Supervisor is updated($ supervisorctl update) ifupdate_supervisoris specified asTrue.Each supervisorctl command specified insupervisorctl_commandsis run in order.Each command specified ininitd_commandsis run in order.UsageAdd a part inbuildout.cfglike so:[buildout]
parts = deploy

[deploy]
recipe = praekelt.recipe.deploy
git_url = git@github.com:me/projectx.git
host = www.protectx.com
root_path = /var/www/projectxRunning the buildout will add a deploy script with the same name as your deploy part in thebin/directory. In this casebin/deploy. The resulting script will deploygit@github.com:me/projectx.gittowww.projectx.com’s/var/www/projectxpath.Optionsas_userUser as which to perform the deploy. Used to setup permissions appropriately and to clone from github.Defaults to ‘www-data’.conf_fileBuildout cfg file with which to run boostrap and buildout.Defaults to ‘buildout.cfg’.cron_commandsCommands to add to theas_usersuser’s crontab.deploy_key_pathPath on host to key to use when cloning the repo.deploy_latest_tagIf True deploy will be performed from latest found tag for active branch. Otherwise deploy will be performed from last commit of the active branch. Defaults to ‘False’.git_branchGit repo branch with which to perform the deploy.git_urlGit repo with which to perform the deploy.Required.hostHostname on which to perform deploy.Required.initd_commandsinit.d commands to run after a completed deploy. i.e.nginx restart.puppet_manifestPuppet manifest file to apply prior to buildout. This will be applied usingpuppet apply <manifest>.python_execPython command with which to boostrap Buildout.Defaults to ‘python’.root_pathRoot path in which to perform the deploy. current/release path structure will be created within this path.Required.shared_resourcesResource paths to copy accross from the current release to the new release on each deploy.supervisorctl_commandssupervisorctl commands to run after a completed deploy. i.e.restart all.update_supervisorWhether or not to update supervisor.Defaults to ‘False’.Full ExampleThe following example illustrates all available options:[buildout]
parts = deploy

[deploy]
recipe = praekelt.recipe.deploy
as_user = www-data
conf_file = production.cfg
deploy_key_path = /var/www/.ssh/projectx_deploy_key
deploy_latest_tag=True
git_branch = production
git_url = git@github.com:me/projectx.git
host = www.protectx.com
initd_commands = nginx restart
puppet_manifest = provision.pp
python_exec = python2.5
root_path = /var/www/projectx
shared_resources =
    eggs
    downloads
    log
    media
update_supervisor = True
supervisorctl_commands = restart all
cron_commands = * * * * * echo foobarThe resulting script will deploy the latest tag found forgit@github.com:me/projectx.git’sproductionbranch  towww.projectx.com’s/var/www/projectxpath as userwww-data. The git repo will be cloned using/var/www/.ssh/projectx_deploy_keyas ssh key. The Puppet manifestprovision.ppwill be applied. Theeggs,downloads,logandmediapaths will be copied from the current release to this new release. The buildout environment will be created usingpython2.5and run usingproduction.cfgas configuration file. After the buildout completes supervisor will be updated andsupervisorctl restart allwill be run as well as/etc/init.d/nginx restart.* * * * * echo foobarwill be added towww-datauser’s crontab.AuthorsPraekelt FoundationShaun SephtonChangelog0.1.3 (2011-06-29)More forcefull supervisor update.0.1.2 (2011-06-28)Allow supervisorctl commands.0.1.1 (2011-06-20)Added command line git creds supply.0.1.0deploy_latest_tag option added.Fail on init.d issues.0.0.9Resolved apply.pp bug.0.0.8Added Puppet manifest provisioning support via puppet_manifest option.Pretty printing.0.0.7Added command env password option.Added force commandline option bypassing confirmation prompts.0.0.6Added support for https git urls.0.0.5Added newest and verbose options.0.0.3Added cron_commands parameter. Allow for certain script argument overrides.0.0.2Fixed branch issue.0.0.1Initial Release