[Fab-user] env.{hosts,exclude_hosts,roles} and some confusion

2011-08-24 Thread Sven Hergenhahn
Hi,

I'm trying to run a task on the servers of a role minus some hosts specified on 
the commandline, but I just cannot get it to remember -x...

Here's my code:

--
import os
import paraproxy
from fabric.api import env, run, puts

EXCLUDE_FILE = '~/.hosts_excluded'

env.roledefs = {
'mailin': [ 'host01', 'host02' ],
'mailout'   : [ 'host03', 'host04' ],
}
env.roledefs['mail'] = env.roledefs['mailin']+env.roledefs['mailout']

def set_excludes(excludes=EXCLUDE_FILE):
with open(os.path.expanduser(excludes)) as fd:
env.exclude_hosts.extend([ host.strip() for host in fd.readlines() ])


puts(genrating hostlists...)
puts(Excludes from cli: %s % ', '.join(env.exclude_hosts))
set_excludes()
puts(Excludes cli/file: %s % ', '.join(env.exclude_hosts))
puts(... done)

def do_date():
run('date')


% /opt/python-2.7/bin/fab -f roles.py -R mail -x host01,host02 do_date
genrating hostlists...
Excludes from cli: host01, host02
Excludes cli/file: host01, host02, x204, x404, x203, x403, x25
... done
[host01] Executing task 'do_date'
[host01] run: date
[host01] out: Thu Aug 18 15:04:44 CEST 2011
[host01] out: 
[host02] Executing task 'do_date'
[host02] run: date
[host02] out: Thu Aug 18 15:04:45 CEST 2011
[host02] out: 
[host03] Executing task 'do_date'
[host03] run: date
[host03] out: Thu Aug 18 15:04:46 CEST 2011
[host03] out: 
[host04] Executing task 'do_date'
[host04] run: date
[host04] out: Thu Aug 18 15:04:46 CEST 2011
[host04] out: 

Done.

Doh, -x ignored...

even a simple 
/opt/python-2.7/bin/fab -f roles.py -R mailin -x x601 do_date or 
/opt/python-2.7/bin/fab -f roles.py -H x601 -x x601 do_date

do not exclude the host.

It seems I don't completely get how and when hosts, exclude_hosts and roles are 
mixed to pass on to a task.

And yes, I have read the manual. Any other documentation I missed or can 
somebody offer some explanations?

Thanks in advance,
Sven


___
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user


Re: [Fab-user] env.{hosts,exclude_hosts,roles} and some confusion

2011-08-24 Thread Jeff Forcier
On Wed, Aug 24, 2011 at 5:04 AM, Sven Hergenhahn sve...@gmx.net wrote:

 And yes, I have read the manual. Any other documentation I missed or can 
 somebody offer some explanations?

When things don't work as expected, there's usually two causes: your
misunderstanding (which you addressed by reading the docs) or a bug
(which you probably forgot to look for ;)).

This is a known bug, and I'll be fixing it soon hopefully as it's kind
of crappy to have a new feature be mostly broken:

https://github.com/fabric/fabric/issues/373

Best,
Jeff

-- 
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org

___
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user


[Fab-user] env.{hosts,exclude_hosts,roles} and some confusion

2011-08-19 Thread Sven Hergenhahn
Hi,

I'm trying to run a task on the servers of a role minus some hosts specified on 
the commandline, but I just cannot get it to remember -x...

Here's my code:

--
import os
import paraproxy
from fabric.api import env, run, puts

EXCLUDE_FILE = '~/.hosts_excluded'

env.roledefs = {
'mailin': [ 'x601', 'x602' ],
'mailout': [ 'x603', 'x604' ],
}
env.roledefs['mail'] = env.roledefs['mailin']+env.roledefs['mailout']

def set_excludes(excludes=EXCLUDE_FILE):
with open(os.path.expanduser(excludes)) as fd:
env.exclude_hosts.extend([ host.strip() for host in fd.readlines() ])


puts(genrating hostlists...)
puts(Excludes from cli: %s % ', '.join(env.exclude_hosts))
set_excludes()
puts(Excludes cli/file: %s % ', '.join(env.exclude_hosts))
puts(... done)

def do_date():
run('date')


% /opt/python-2.7/bin/fab -f roles.py -R mail -x x601,x602 do_date
genrating hostlists...
Excludes from cli: x601, x602
Excludes cli/file: x601, x602, x204, x404, x203, x403, x25
... done
[x601] Executing task 'do_date'
[x601] run: date
[x601] out: Thu Aug 18 15:04:44 CEST 2011
[x601] out: 
[x602] Executing task 'do_date'
[x602] run: date
[x602] out: Thu Aug 18 15:04:45 CEST 2011
[x602] out: 
[x603] Executing task 'do_date'
[x603] run: date
[x603] out: Thu Aug 18 15:04:46 CEST 2011
[x603] out: 
[x604] Executing task 'do_date'
[x604] run: date
[x604] out: Thu Aug 18 15:04:46 CEST 2011
[x604] out: 

Done.

Doh, -x ignored...

It seems I don't completely get how and when hosts, exclude_hosts and roles are 
mixed to pass on to a task.

And yes, I have read the manual.

Thanks in advance,
Sven


-- 
Sven Hergenhahn
Heidelberg.Germany.Earth.

GPG Key 0x0DCE97AB Fingerprint E452 94A5 A426 1CA5 B321  5A71 D1AE 3696 0DCE 
97AB

___
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user