[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] Populating env.hosts?
From: |
Jeff Forcier |
Subject: |
Re: [Fab-user] Populating env.hosts? |
Date: |
Mon, 7 Feb 2011 10:35:53 -0500 |
On Mon, Feb 7, 2011 at 5:21 AM, Xavier Ordoquy <address@hidden> wrote:
> Hi there,
>
> You'll also need to define env.host_string for each of your host.
> Fabric automatically populate it when called from command line but not within
> a python script.
>
> Regards,
> Xavier.
Xavier's correct, env.hosts updates will only affect tasks that run
later on, so it only makes sense to update env.hosts outside of a task
function (i.e. at module level), or in an env-setting task which you
run prior to running other tasks (i.e. fab set_my_hosts do_some_work).
See also http://docs.fabfile.org/0.9.3/usage/execution.html#connections
-Jeff
> Le 7 févr. 2011 à 11:00, address@hidden a écrit :
>
>> Hi
>>
>> Anyone have any idea why this does not work? If I print env.hosts out,
>> all the ip's are there perfectly. For example : env.hosts
>> ['192.168.1.1', '192.168.1.2', '192.168.1.3']
>>
>> However when I run my fabric script, I get
>>
>> No hosts found. Please specify (single) host string for connection:
>>
>> def servers():
>>
>> """
>> servers()
>>
>> Gets a list of servers to populate env.hosts.
>> """
>>
>> env.hosts = []
>>
>> for server_name in config.options('Servers'):
>> ip_address = config.get('Servers', server_name)
>> env.hosts.append(ip_address)
>>
>> print "env.hosts %s" % env.hosts
>> env.user = 'deployboy'
>> env.key_filename = [ './secret.pem' ]
>> run('hostname')
>>
>> End - servers
>>
>> _______________________________________________
>> Fab-user mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/fab-user
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>
--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org