rax-maas / dreadnot

deploy without dread
Apache License 2.0
631 stars 61 forks source link

Dreadnot - deploy without dread

Build Status npm Inline docs License

Dreadnot is a 'one click' deploy tool written in Node.js.

Dreadnot was heavily inspired by Etsy's Deployinator.

Deploy all the branches

Configuration

Dreadnot loads its configuration from a javascript file:

exports.config = {
  // The name of this Dreadnot instance, used for display
  name: 'Example Dreadnot',

  // Each Dreadnot instance supports one environment such as 'dev', 'staging'
  // or 'production'
  env: 'staging',

  // The data root Dreadnot will use
  data_root: '/var/dreadnot',

  // Base URL to access dreadnot (used in IRC, email, Hipchat)
  default_url: 'http://example.com',

  // Dreadnot uses an htpasswd file (with support for bcrypt, md5 and sha1) for auth
  htpasswd_file: '/etc/dreadnot/htpasswd',

  // Each stack represents a code base that should be deployed to one or more regions
  stacks: {

    // For a stack named 'webapp', there should be a 'webapp.js' file in the
    // stacks directory
    webapp: {
      // What branch to look in for the latest revision of the code base
      tip: 'master',

      // How long to cache the latest revision of the code base
      tip_ttl: 120 * 1000,

      // What regions this stack should be deployed to
      regions: ['ord1'],

      // Stacks should implement dryrun for testing
      dryrun: true
    }
  },

  // The GitHub organization you provide is used to build URLs for your stacks
  github: {
    organization: 'racker'
  },

  // Plugins provide optional functionality such as notifications. Any plugins
  // that are not configured won't be used.
  plugins: {

    // An IRC notification plugin
    irc: {
      nick: 'staging-dreadnot',
      channels: {'irc.freenode.net': ['#public-channel', '#private-channel pass']}
    },

    // An email notification plugin
    email: {
      server: {
        user: 'staging-dreadnot@example.com',
        password: '',
        host: 'smtp.example.com',
        ssl: true
      },
      to: 'systems@example.com',
      from: 'staging-dreadnot@example.com'
    },

    // A Hipchat notification plugin
    hipchat: {
      name: 'Dreadnot',
      apiKey: '123456789abcdefg',
      rooms: [
        1234,
        5678
      ]
    }
  }
};

Stacks

Dreadnot looks in a directory (by default ./stacks, but this can be changed from the command line) for "stack files". A stack file is simply a javascript file that exports

Tasks

In the configuration used by Rackspace Cloud Monitoring, a deployment looks something like:

  1. Build: verify that the requested revision has been successfully built and that all tests pass.
  2. Prepare: remove the region being deployed from the load balancer rotation, redirecting all traffic to another region.
  3. Execute: use a chef search to locate all servers in the region, then ssh to each in parallel to upgrade the code.
  4. Validate: execute checks against each upgraded service to verify that it is functioning properly.
  5. Restore: restore the region to the load balancer rotation.

Imporantly, Dreadnot knows nothing about the hosts to which it is deploying - if it did, we would have to modify our Dreadnot configuration every time we added or removed a machine from our environment. Instead, we rely on chef (although anything that knows about your servers will work) to give us an up-to-date list of all hosts in a given region. In smaller deployments it might be suitable to hardcode a list of hosts.

FAQ

Does Dreadnot support SVN?

Dreadnot supports Node.js - you can use any technology or topology that suits you, as long as you can find a library for it.

Development

To create a development environment, you'll need Vagrant and Virtualbox. Once installed, run:

    vagrant up

Then visit http://localhost:8000

Log into the VM by running and running common commands:

    vagrant ssh
    sudo cat /var/log/upstart/dreadnot.log

Running Dreadnot

    npm install dreadnot -g

Alternatively, when developing, you can find a compiled dreadnot binary in the bin folder.

Dreadnot takes a number of options on the command line. The defaults are:

  dreadnot -c ./local_settings.js -s ./stacks -p 8000

This will start dreadnot with the specified config file and stack directories, listening on port 8000.