[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] setting hosts
From: |
Jeremy M. Jones |
Subject: |
Re: [Fab-user] setting hosts |
Date: |
Mon, 11 May 2009 17:21:11 -0400 |
I'm still getting an attribute error when I have this:
1 from fabric.api import run, put, roles, env
2
3 env.user = 'jmjones'
4 env.roles.home = ['mydomain']
5 env.roles.ezr = ['192.168.1.20']
6 #env.hosts = []
7
8 @roles('home', 'ezr')
9 def all():
10 pass
11
12 @roles('ezr')
13 def ezr():
14 pass
15
16 @roles('home')
17 def home():
18 pass
19
20 def ls():
21 run('ls')
Here's the command I used:
(fab_git)address@hidden:~/fab/home$ fab ezr ls
/home/jmjones/python/fab_git/lib/python2.6/site-packages/
pycrypto-2.0.1-py2.6-linux-x86_64.egg/Crypto/Hash/SHA.py:6:
DeprecationWarning: the sha module is deprecated; use the hashlib
module instead
/home/jmjones/python/fab_git/lib/python2.6/site-packages/
pycrypto-2.0.1-py2.6-linux-x86_64.egg/Crypto/Hash/MD5.py:6:
DeprecationWarning: the md5 module is deprecated; use hashlib instead
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/fabric/main.py", line 339, in main
File "build/bdist.linux-x86_64/egg/fabric/main.py", line 116, in
load_fabfile
File "/home/jmjones/fab/home/fabfile.py", line 4, in <module>
env.roles.home = ['mydomain']
File "build/bdist.linux-x86_64/egg/fabric/state.py", line 64, in
__getattr__
AttributeError
- jmj
On May 11, 2009, at 1:28 PM, Patrick J McNerthney wrote:
Try:
env.roles.webserver = ['www1', 'www2']
env.roles.dbserver = ['db1']
@roles('webserver', 'dbserver')
def my_func():
pass
Pat McNerthney
ClearPoint Metrics, Inc.
Jeremy M. Jones wrote:
What's the canonical way of creating groups of hosts and then
selecting that group (or sets of groups) to execute for a
particular function at runtime? I initially thought that it
included using the roles, but I can't get that working right.
According the the docstrings in the decorators.py module, using
roles should look like this:
41 env.webserver = ['www1', 'www2']
42 env.dbserver = ['db1']
43
44 @roles('webserver', 'dbserver')
45 def my_func():
46 pass
But when I run something like this:
1 from fabric.api import run, put, roles
2 from fabric.state import env
3
4 env.user = 'myuser'
5 env.home = ['my.host.com']
6 env.ezr = ['192.168.1.20']
7 env.hosts = []
8
9 @roles('home', 'ezr')
10 def all():
11 pass
12
13 @roles('ezr')
14 def ezr():
15 pass
16
17 @roles('home')
18 def home():
19 pass
20
21 def ls():
22 run('ls')
With a command line looking like this::
fab ezr ls
I get an error like this::
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/fabric/main.py", line 391, in
main
File "build/bdist.linux-x86_64/egg/fabric/main.py", line 305, in
get_hosts
KeyError: 'ezr'
I figured that attributes on the "env" object would be interpreted
as roles, but that doesn't appear to be the case. And even if this
worked properly, I'm not sure that this would do what I wanted it
to do. It seems that it would set the .roles attribute on the
decorated functions with the specified roles rather than adding the
hosts for those roles to some global run registry or something like
that.
Anyway, are there working examples for the current 0.9 release that
will allow me to sort of do what I want to do? I can monkey around
with sets and the hosts list with various functions, but it seems
like there should be a cleaner to do this.
- jmj
_______________________________________________
Fab-user mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/fab-user