fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Feature request: Host reference


From: Jeff Forcier
Subject: Re: [Fab-user] Feature request: Host reference
Date: Sat, 2 May 2009 16:25:11 -0400

Hey Patrick,

Yea, this idea has been floated recently. I'm not 100% sure exactly
what API I think will work best, but the general idea is definitely
the same as what you have below. I'd be surprised if Fabric 0.9 final
goes out without something like this being present, let's put it that
way :)

-Jeff

On Sat, May 2, 2009 at 4:20 PM, Patrick J McNerthney
<address@hidden> wrote:
> 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():
>   run('foo')
>   sudo('bar')
>
> 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:
>
> @hosts("build")
> def build_it():
>   ec2_start()
>   run("the_build_command")
>
> Just putting a thought out there.
>
> Pat McNerthney
> ClearPoint Metrics, Inc.
>
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>




reply via email to

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