Intro

So, recently I’ve been rather facinated by Node.js. Pretty nice little language, really easy to learn and really flexible. I won’t bore anybody with details of learning or walking through a tutorial, since there are plenty of those out there.

Instead we’re installing dreadnot from Rackspace.

Why? Because I like it, it works and it’s written in node.

I’m assuming you have node installed based on instructions here. You will also need to have git installed.

Getting Started

I prefer to run dreadnot under it’s own user account, that way it will limit the amount of damage it can do if it’s compromised. It also should start when the system starts up, so we’ll create a upstart script for it since we’re running under Ubuntu.

User Account Creation

It’s pretty straight forward:

sudo groupadd dreadnot
sudo useradd -d /opt/dreadnot -c "dreadnot" -g dreadnot -m -r -s /bin/bash dreadnot
sudo passwd dreadnot

Remember the password you assign, you’ll need it for a little while.

We need to be able to log in to the account, so:

ssh dreadnot@localhost
mkdir .ssh
touch .ssh/authorized_keys
chmod go-rwx .ssh/authorized_keys

Copy your public key into the authorized_keys file and you should be able to log in to the account with using the username and password

Installing Dreadnot

Really pretty easy:

sudo npm install -g dreadnot

Configuring

We’ll use the example dreadnot settings file, slightly modified to make this work. Obviously, you’ll want to expand this out to make what you need to do.

ssh dreadnot@localhost

I prefer to make the changes as the dreadnot user, so I don’t have to worry about permissions.

touch ~/local_settings.js
wget https://raw.github.com/racker/dreadnot/master/example/htpasswd
mkdir ~/stacks
cd ~/stacks
wget https://raw.github.com/racker/dreadnot/master/example/stacks/tapkick.js
cd ~/
git clone git://github.com/philips/tapkick.git /opt/dreadnot/data/tapkick

Copy and Paste the following into the local_settings.js file.

exports.config = {
  name: 'Tapkick Deploy',
  env: 'production',
  data_root: '/opt/dreadnot/data',
  htpasswd_file: '/opt/dreadnot/htpasswd',
  secure: false,
  login_required: false,
  stacks: {
    tapkick: {
      git_url: 'git://github.com/philips/tapkick.git',
      tip: 'master',
      tip_ttl: 120 * 1000,
      regions: ['all']
    },
  },
  tapkick_dir: '/opt/dreadnot/data/tapkick',
  github: {
    organization: 'philips'
  },
};

Now, lets see if it will run interactively:

/usr/bin/dreadnot -c ~/local_settings.js -s ~/stacks -p 8000

Now then, open the web browser and go to the ip address of the machine and port 8000, ie http://deploymachine:8000/. You should see something. When you click on the region and then deploy, it should work!

Make it start when the machine does

On Ubuntu, you have to use upstart. Okay, maybe you don’t have to, but I prefer it.

sudo touch /etc/init/dreadnot.conf
sudo nano /etc/init/dreadnot.conf

And copy the following:

start on runlevel [2345]

script
        exec sudo dreadnot /usr/bin/dreadnot -c /opt/dreadnot/local_settings.js -s /opt/dreadnot/stacks/ -p 8000
end script

To start it up:

sudo start dreadnot
sudo initctl list | grep dreadnot

And that should be it!

Customizing

The example local_settings file is just that, an example. I don’t know what tapkick, and I don’t really care. You can use this to deploy whatever by altering the local_settings file and adding the correct things in the stacks folder.



Published

04 April 2012

Category

devops

Tags