fab-user
[Top][All Lists]
Advanced

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

[Fab-user] Re: specifying login and password?


From: Timothee Besset
Subject: [Fab-user] Re: specifying login and password?
Date: Wed, 18 Feb 2009 12:30:50 -0600
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

Timothee Besset wrote:
> Hello,
>
> New user .. finding documentation very, very scarce ..
>
> Is there a way to specify login and password along with the hosts list?
> I want to use fab to configure a fairly large number of machines with
> different access settings.
>
> Best,
> TTimo
>
>   
For reference, here's what I'm doing right now, which works but is
obviously very contrived:

#!/usr/bin/env python
# use fab to access multiple hosts

import subprocess

host_root = {
'host1' : 'pass1',
'host2' : 'pass2',
    }

sorted_keys = host_root.keys()
sorted_keys.sort()

for host in sorted_keys:
    f = file( 'fabfile.py', 'w' )
    f.write( 'config.fab_hosts = [ %s ]\n' % repr( host ) )
    f.write( 'config.fab_user = \'root\'\n' )
    f.write( 'config.fab_password = %s\n' % repr( host_root[ host ] ) )
    f.write( """
def hello_remote():
    "Prints hello on the remote hosts."
    run("echo hello from $(fab_host) to $(fab_user).")
""" )
    f.close()
    subprocess.check_call( [ '/usr/bin/fab', 'hello_remote' ] )





reply via email to

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