Overview

Stagehand

Stagehand is a packaged-up series of scripts and functions that I use to set up a new server. It is designed to do the following:

  • Set up a server management environment (bootstrap.py)
  • Take care of the initial connection to a new server (firstconnect.py)
  • Set up server configuation and management (salt or littlechef)

For those wanting to use stagehand, that is the order in which they should be used.

Summary

Assuming that virtualenv and virtualenvwrapper are installed:

mkvirtualenv stagehand
workon stagehand
cdvirtualenv
curl -O https://bitbucket.org/vanl/stagehand/downloads/bootstrap.py
python bootstrap.py
fab interactive firstconnect

Bootstrap

Usage: python bootstrap.py (from within a virtualenv)

The bootstrap.py file is designed to be run from within a virtualenv. It also assumes that git (or hg-git aliased to git) and hg are available in the $PATH. It has no dependencies outside of the stdlib. It works on both windows and Mac OS X/Linux.

The bootstrap file is available as a download from stagehand's download page. The direct link is:

https://bitbucket.org/vanl/stagehand/downloads/bootstrap.py

Bootstrap.py sets up Fabric, and clones the rest of the stagehand project from Bitbucket as the "fabfile" package. It also drops in a .pth file so that the package is importable via "import fabfile as stagehand".

Firstconnect

Usage: fab interactive firstconnect

Many times a new server from Linode or AWS is not ready to be managed just yet - you need to set the hostname, push keys to the server, set up a non-privileged user, and install some basic packages. Stagehand is not meant to be a comprehensive server management solution; it is just designed to move your server from newly provisioned to ready to be managed.

A couple notes about the stagehand fabfile package:

  • Firstconnect is designed to be used in conjuction with a relatively recent Debian or Ubuntu box. It explicitly uses Unixisms/Debianisms (e.g. apt-get) to set things up. It has been tested and used on Ubuntu 10.04, 10.10, 11.04, and 11.10. If there are any problems with any of these, please let me know.
  • The "firstconnect" command can be used non-interactively, but the correct host/user information has to be given via fab's command-line options. The interactive mode asks you questions to guide the deployment.
  • Firstconnect makes sure that the requested version of Python is set up on the new server, with the default being 2.7. If that version is not available (for example, on Ubuntu 10.04), then Python is downloaded, built, and installed into /usr/local from source (using make altinstall).
  • Firstconnect installs a number of packages that help with compiling stuff later. Look at stagehand.constants.APT_PREREQS for a list.
  • A couple of Python-implemented projects are installed into their own isolated virtualenvs and then symlinked into the $PATH. Notably Fabric, Mercurial, and Salt are installed this way.
  • This started out specific to a Linode server, so there may be some other things that would be useful to do on first connect (on AWS, Cloud Servers, etc.). Patches welcome.

Salt

See the standard salt documentation for details.