Hi Wawrzek,

if you need to specify a host per task, I would recommend you  to use the
@hosts decorator:

@hosts('localhost)
def test():
    print "Hosts:", env['hosts']
    print "Host_string", env['host_string']
    run('uname -a')


Anyway, check out the documentation at
http://docs.fabfile.org/en/latest/usage/execution.html#how-host-lists-are-constructed
It explains how the hosts lists are constructed and how can you use it. I
usually use the -H flag in the fab command.

Regards

2014-10-03 11:37 GMT+02:00 Wawrzek Niewodniczanski <m...@wawrzek.name>:

> Hi,
>
> For quite a long time I've been using various fabric based scripts.
> Recently I hit very strange problem. Following short script
> illustrates my issue.
>
>
> #!/usr/bin/env python
>
> import fabric
> from fabric.api import env, run
>
> env.hosts = ['localhost']
>
> def test():
>     print "Hosts:", env['hosts']
>     print "Host_string", env['host_string']
>     run('uname -a')
>
>
> test()
>
>
> And when I run It I got:
>
> #>./fabric-min.py
> Hosts: ['localhost']
> Host_string None
> No hosts found. Please specify (single) host string for connection:
> localhost
> [localhost] run: uname -a
>
>
> I copied content to fabfile.py and got the same:
>
> #>fab test
> Hosts: ['localhost']
> Host_string None
> No hosts found. Please specify (single) host string for connection: ^C
> Stopped.
>
> What do I  do wrong?
>
>
> I run my tests at Ubuntu 14.04 LTS with
> Python 2.7.6
> Fabric 1.8.2
> Paramiko 1.10.1
>
>
> Thanks,
> Wawrzek
> --
> Dr  Wawrzyniec Niewodniczański    or Wawrzek for short
>   PhD in Quantum Chemistry  & MSc in Molecular Engineering
>    WWW: http://wawrzek.name E-MAIL: j...@wawrzek.name
>       Linux User #177124
>
> _______________________________________________
> Fab-user mailing list
> Fab-user@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/fab-user
>



-- 
Carlos García
Director de Operaciones
Tel. 695 624 167 - 902 620 100
www.stoneworksolutions.net

AVISO DE CONFIDENCIALIDAD
Tanto este mensaje como todos los posibles documentos adjuntos al mismo son
confidenciales y están dirigidos exclusivamente a los destinatarios de los
mismos. Por favor, si Ud no es uno de dichos destinatarios, notifíquenos
este hecho y elimine el mensaje de su sistema. Queda prohibida la copia,
difusión o revelación de su contenido a terceros sin el previo
consentimiento por escrito del remitente. En caso contrario, vulnerarán la
legislación vigente
_______________________________________________
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to