fab-user
[Top][All Lists]
Advanced

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

[Fab-user] Using context_managers.settings with hosts


From: Dave Peck
Subject: [Fab-user] Using context_managers.settings with hosts
Date: Wed, 9 Mar 2011 17:50:17 -0800

I want to dynamically populate env.hosts based on a parameter passed into a command.

I can see that the settings() context manager is setting env.hosts correctly, but the sudo() command inside the block doesn't pick up on it:

from fabric.context_managers import settings

env.hosts = [] # These will be selected dynamically

def mycommand(cloudformation_stack_name):
with(settings(hosts=_host_list_from_cfn_stack_name(cloudformation_stack_name)):
# I can see that env.hosts is set correctly here.
# But: the following sudo() call doesn't seem to know it!
sudo('echo hello')

My read of the documentation for settings() is that this should work. There's nothing in the documentation that says "dynamically modify settings -- unless they're settings that you can't dynamically modify." 

That said, I know there are issues modifying env.hosts within a task and I assume this may be a permutation. 

What in the fabric codebase leads to this fundamental (and frustrating) limitation? Outside of having a separate task dynamically pick hosts, what's a good workaround?

Thanks,
Dave




reply via email to

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