Skip to main content

Buildout recipe making versioned remote deploys trivial.

Project description

praekelt.recipe.deploy

Buildout recipe making versioned remote deploys trivial.

Creates a bin/ script with which you can easily deploy buildouts to remote servers. Uses Fabric to 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:

  1. The remote host as specified in host is accessed.

  2. A new release path structure is created using this pattern: <root_path>/releases/<release_timestamp>.

  3. The git repo as specified in git_url is cloned.

  4. The newly cloned repo’s branch is switched to the branch as specified in git_branch. If git_branch is not specified no switch occurs.

  5. The repo is switched to the latest tag for the active branch if deploy_latest_tag is specified as True. If deploy_latest_tag is not specified deploy will be performed from last commit of the active branch.

  6. A Puppet manifest as specified in puppet_manifest is applied if provided.

  7. Shared resources as specified in shared_resources are copied from the current release(if present) to the newly created release.

  8. The Buildout’s boostrap.py is run using the python executable as specified in python_exec and a Buildout configuration file as specified in conf_file. python is used by default if python_exec is not specified, buildout.cfg is used by default if conf_file is not specified.

  9. The Buildout is run using a Buildout configuration file as specified in conf_file. buildout.cfg is used by default if conf_file is not specified.

  10. The <root_path>/current symlink is updated to point to newly created release.

  11. Supervisor is updated($ supervisorctl update) if update_supervisor is specified as True.

  12. Each command specified in initd_commands is run in order.

Usage

Add a part in buildout.cfg like 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/projectx

Running the buildout will add a deploy script with the same name as your deploy part in the bin/ directory. In this case bin/deploy. The resulting script will deploy git@github.com:me/projectx.git to www.projectx.com’s /var/www/projectx path.

Options

as_user

User as which to perform the deploy. Used to setup permissions appropriately and to clone from github. Defaults to ‘www-data’.

conf_file

Buildout cfg file with which to run boostrap and buildout. Defaults to ‘buildout.cfg’.

cron_commands

Commands to add to the as_users user’s crontab.

deploy_key_path

Path on host to key to use when cloning the repo.

deploy_latest_tag

If 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_branch

Git repo branch with which to perform the deploy.

git_url

Git repo with which to perform the deploy. Required.

host

Hostname on which to perform deploy. Required.

initd_commands

init.d commands to run after a completed deploy. i.e. nginx restart.

puppet_manifest

Puppet manifest file to apply prior to buildout. This will be applied using puppet apply <manifest>.

python_exec

Python command with which to boostrap Buildout. Defaults to ‘python’.

root_path

Root path in which to perform the deploy. current/release path structure will be created within this path. Required.

shared_resources

Resource paths to copy accross from the current release to the new release on each deploy.

update_supervisor

Whether or not to update supervisor. Defaults to ‘False’.

Full Example

The 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
cron_commands = * * * * * echo foobar

The resulting script will deploy the latest tag found for git@github.com:me/projectx.git’s production branch to www.projectx.com’s /var/www/projectx path as user www-data. The git repo will be cloned using /var/www/.ssh/projectx_deploy_key as ssh key. The Puppet manifest provision.pp will be applied. The eggs, downloads, log and media paths will be copied from the current release to this new release. The buildout environment will be created using python2.5 and run using production.cfg as configuration file. After the buildout completes supervisor will be updated and /etc/init.d/nginx restart will be run. * * * * * echo foobar will be added to www-data user’s crontab.

Authors

Praekelt Foundation

  • Shaun Sephton

Changelog

0.1.1 (2011-06-20)

  1. Added command line git creds supply.

0.1.0

  1. deploy_latest_tag option added.

  2. Fail on init.d issues.

0.0.9

  1. Resolved apply.pp bug.

0.0.8

  1. Added Puppet manifest provisioning support via puppet_manifest option.

  2. Pretty printing.

0.0.7

  1. Added command env password option.

  2. Added force commandline option bypassing confirmation prompts.

0.0.6

  1. Added support for https git urls.

0.0.5

  1. Added newest and verbose options.

0.0.3

  1. Added cron_commands parameter. Allow for certain script argument overrides.

0.0.2

  1. Fixed branch issue.

0.0.1

  1. Initial Release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

praekelt.recipe.deploy-0.1.1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distributions

praekelt.recipe.deploy-0.1.1-py2.7.egg (18.5 kB view details)

Uploaded Source

praekelt.recipe.deploy-0.1.1-py2.6.egg (18.6 kB view details)

Uploaded Source

File details

Details for the file praekelt.recipe.deploy-0.1.1.tar.gz.

File metadata

File hashes

Hashes for praekelt.recipe.deploy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7312428260de3410426885bcc3f88fd497873c64faab3962017b5eb3a73f699a
MD5 375c938c1eb731c3197cfea3d52ef358
BLAKE2b-256 43b6b52f1dde5427c162e98b24f7228a595c60a8dc8f93d46680bb8c799552f3

See more details on using hashes here.

File details

Details for the file praekelt.recipe.deploy-0.1.1-py2.7.egg.

File metadata

File hashes

Hashes for praekelt.recipe.deploy-0.1.1-py2.7.egg
Algorithm Hash digest
SHA256 00cdaede658b22707b1c2620194ec3b2959e5c1870359a8655c945fdfb665b9d
MD5 3d95fd9eb50787f7c9b6be93eec61bfe
BLAKE2b-256 960d60c1729855faadcd871e0cf39556fe54d9b8fe0c945c2caffb80b50ba2ab

See more details on using hashes here.

File details

Details for the file praekelt.recipe.deploy-0.1.1-py2.6.egg.

File metadata

File hashes

Hashes for praekelt.recipe.deploy-0.1.1-py2.6.egg
Algorithm Hash digest
SHA256 5bfa4f900fbe82632fbe9b54328bec6fe5b3b66dc7e2e1ace095e345669128f3
MD5 21b2a69c59e409c438ec094de51d0fdb
BLAKE2b-256 3f214fbd44379738361bf4bb06d312f3b2c73f7efe2a1d89f01ee6256eef3aec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page