fab-user
[Top][All Lists]
Advanced

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

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


From: Sven Hergenhahn
Subject: [Fab-user] env.{hosts,exclude_hosts,roles} and some confusion
Date: Thu, 18 Aug 2011 15:10:21 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.23) Gecko/20090817 Thunderbird/2.0.0.23 Mnenhy/0.7.5.0

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



reply via email to

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