fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] combining multiple tasks on multiple targets into a singl


From: Thomas GRATTON
Subject: Re: [Fab-user] combining multiple tasks on multiple targets into a single function
Date: Wed, 13 Jul 2011 18:55:06 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10

Hi there,

Before, thanks to Fabric developpers, keep da good work up ;)

I'm using Fabric & Python since 1 week, essentialy to grab informations on my Linux servers.

Chris, first :

You've to use RSA public keys. Then yu'll able to use SSH as this :

from fabric.api import *

env.roledefs['debian_sarje'] = ['myserver1','myserver2','myserver3'...]
env.roledefs['redhat_as_6'] = ['myserver5','myserver8','myserver0'...]

@roles('redhat_as_6','debian_sarje')

my_function():

        # verbose or no
        with settings(
        hide('warnings', 'running', 'stderr','stdout'),
        warn_only=False
        ):

                # grab info
                hostname = run('hostname -s')
                kernel = run('uname -r')

        ...

I must say that the best thing is to read this before scripting : http://learnpythonthehardway.org/book/

My two cents... Hope it'll help you ;)

PS : sorry for bad english -__-

On 11/07/2011 19:36, Chris Steel wrote:
I want to be able to run a single fab command, for example:

     fab combined_task

so that a number of tasks take place on various target hosts with no
additional input required.

It seem no matter what I try I get prompted for a connection string when
switching target hosts. Any ideas? This is a simplified example of the
collection of fabfiles I have inherited. Perhaps I need to modify them
to make use of roles?

def dev():
     env.hosts    = ['127.0.0.1']
     env.user     = 'uname'
     env.passwrod = 'password'

def repo():
     env.hosts    = ['10.0.1.10']
     env.user     = 'uname'
     env.passwrod = 'password'

@hosts(repo)
def task1():
     run('ls -al')

@hosts(dev)
def task2():
     run('echo test > my_test'')

def combined_task():
     task1()
     task2()

--
Christopher Steel

Voice of Access



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

--
Thomas GRATTON
Rectorat de Versailles - SIGE 3 - Equipe Systèmes et Réseaux
3, Bd de Lesseps - 78017 Versailles Cedex
Tel : 01.30.83.47.62



reply via email to

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