[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] Feature request: Host reference

From: Patrick J McNerthney
Subject: [Fab-user] Feature request: Host reference
Date: Sat, 02 May 2009 16:20:06 -0400
User-agent: Thunderbird (X11/20090409)

Something I find very useful is not using the ssh host name as the name used in Fabric to identify which host(s) to operate on, but to instead use an assigned name. By using something like the following dictionary:

env.host_configuration = {
       "production": {
           "host"     : "www.production.com",
           "user"     : "production",
           "keyfile" :  "~/.ssh/production.id_rsa",
       "testing": {
           "host"     : "www.testing.com",
           "user"     : "testing",
           "keyfile" :  "~/.ssh/testing.id_rsa",

Then, a command might look something like this:

def staging():
   env.hosts = ['production']

def production():
   env.hosts = ['testing']

def deploy():

An obvious use case is allowing for different passwords or private keys per hosts.

What I have been doing with this kind of setup is performing some tasks that dynamically determine the ssh host name in my own commands. For example, I start out with something like the following structure:

env.host_configuration = {
       "build": {
           "image"     : "ami-375abd5f",
           "type"         : "m1.small",
           "zone"        : "us-east-1b",
           "keyaws"   : "aws-ec2",
           "user"        : "build",
           "keyfile:     :  "~/.ssh/aws-ec2.id_rsa",
           "volume"   : "vol-8fa043e7",
           "device"    : "/dev/sdf",
           "mount"    : "/mnt/ebs",

I then have a "ec2_start" command that iterates through all selected hosts and starts an Amazon ec2 instance using the configuration information. Once the instance is running, this "ec2_start" command then populates the host_configuration information with the host name that the instance got assigned. So the rest of my fabfile.py might look something like this:

def build_it():

Just putting a thought out there.

Pat McNerthney
ClearPoint Metrics, Inc.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]