fab-user
[Top][All Lists]
Advanced

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

[Fab-user] env.user and prev_user in the presence of env.hosts


From: Justin Donaldson
Subject: [Fab-user] env.user and prev_user in the presence of env.hosts
Date: Tue, 12 Apr 2011 22:41:59 -0700

First off, congrats on fabric, this is a really useful tool.

I'm using fab with some cloud based infrastructure, especially in situations where host names are transient, and a number of other configuration/connection issues come into play.

I was confused by some behavior in fabric.  When you set env.user in one function, it will typically be passed on to the next, just like any other field set on env.

However, when env.hosts are present, env.user is discarded without any indication of what's happening. 

I had one workflow set up as follows:

#fabfile
...
def build_ami() : # build an amazon ami, retrieve the public dns name, and use it to update env.hosts

def user(name) : # set env.user to the name argument

def ssh(index=0) : # ssh into the first host in env.hosts
...

I was building ubuntu ami's, and running the command as follows:

$> fab build_ami user:ubuntu ssh

However, I soon learned that once env.hosts are set (in build_ami), user:ubuntu will not actually change env.user (it saves the value in prev_user, and resets it after ssh returns), and ssh will try to login with the original user name.
I could set the name inside build_ami with an argument, but I wanted to use the original env.user inside this function for ec2 tagging purposes.  I was able to work around this by using env.user_local

The question is, what is the purpose for this behavior?  I couldn't find anything in the documentation that explained why it was doing this.

The next question is, is there a group of people that are sharing best tips, etc. for using fabric on cloud based systems?  Is there a better option? I'd rather not invent the wheel, or force square pegs in round holes here. 


Thanks again,
-Justin
--
Justin Donaldson, BigML, Inc.
o: 313-31BIGML | c: 919-BUZZJJD


reply via email to

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