Ryan,

I have found it is very convenient to use fabric as a library (rather than
using  "fab myfunction" ) for this type of purpose.

For instance, you can alter the env.host_string at runtime with any target
host as desired.

-William

On Thu, Jul 12, 2012 at 11:00 AM, <fab-user-requ...@nongnu.org> wrote:

> Send Fab-user mailing list submissions to
>         fab-user@nongnu.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.nongnu.org/mailman/listinfo/fab-user
> or, via email, send a message with subject or body 'help' to
>         fab-user-requ...@nongnu.org
>
> You can reach the person managing the list at
>         fab-user-ow...@nongnu.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Fab-user digest..."
>
>
> Today's Topics:
>
>    1. Execute the same tasks in local() and run() (Jorge Vargas)
>    2. Dynamic hosts not supported by -H? (Ryan Bales)
>    3. Re: Execute the same tasks in local() and run() (Todd DeLuca)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 12 Jul 2012 04:05:07 -0400
> From: Jorge Vargas <jorge.var...@gmail.com>
> To: fab-user <fab-user@nongnu.org>
> Subject: [Fab-user] Execute the same tasks in local() and run()
> Message-ID:
>         <
> caosapwn5bmtz0s9eoyfu7g-sc684t_68leeh8qpguy_qsbr...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello,
>
> We are using fabric for development as well as deployment and I'm wondering
> how people are doing command like this.
>
> @task
> def load_fixtures():
>     """Load initial data."""
>     run("venv/bin/python data/fixtures.py")
>
> This code should work for both the developer machine (ie: run local) and
> the deployment machine (ie: use run)
>
> So far what I have done is something like
>
> @task
> def install_db(command=local):
>     """@onetime install of the database"""
>     with prefix("source venv/bin/activate"):
>         command("python manage.py syncdb --migrate")
>
> However that's a bit of a problem as I can't call that command from fab
> just from other fabric scripts.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.nongnu.org/archive/html/fab-user/attachments/20120712/941560fa/attachment.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Thu, 12 Jul 2012 08:26:38 -0500
> From: Ryan Bales <thinkt...@gmail.com>
> To: fab-user <fab-user@nongnu.org>
> Subject: [Fab-user] Dynamic hosts not supported by -H?
> Message-ID:
>         <
> cac5m4j2zofzmudz2qkcr6ifkbptpigiybknr++dv82dymck...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello all,
>
> I'm trying to build a web app around a few fabric scripts, and I need to
> supply a dynamic list of hosts to the scripts.  I saw the -H switch, but it
> apparently only works when env.hosts is defined in the fabric script.  I
> also looked at command-line kwargs for methods, but the methods won't even
> be executed without env.hosts being defined.  Can someone point me in the
> right direction?
>
> Thanks,
> --
> Ryan Bales
> http://thinkt4nk.com/
> http://twitter.com/#!/thinkt4nk
> https://github.com/thinkt4nk
>
>
>
>
>
> --
> Ryan Bales
> http://thinkt4nk.com/
> http://twitter.com/#!/thinkt4nk
> https://github.com/thinkt4nk
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.nongnu.org/archive/html/fab-user/attachments/20120712/7a596f6e/attachment.html
> >
>
> ------------------------------
>
> Message: 3
> Date: Thu, 12 Jul 2012 09:32:04 -0400
> From: Todd DeLuca <todddel...@gmail.com>
> To: Jorge Vargas <jorge.var...@gmail.com>
> Cc: fab-user <fab-user@nongnu.org>
> Subject: Re: [Fab-user] Execute the same tasks in local() and run()
> Message-ID:
>         <
> cajropyadz_esxkyj1ssu37zhkzsc4ynriyqzu7_8u1vkak5...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> The way I deploy to localhost now is to run ssh on my local machine.  That
> way I can access my local machine "remotely" in fabric scripts.  On my mac
> laptop, here is how I enabled remote logins via ssh.  Go to System
> Preferences, choose Sharing.  Select Remote login.  That's it.  This
> approach seems to fit into the fabric model well.
>
> I used to deploy locally by following the advice at
> http://stackoverflow.com/questions/6725244/running-fabric-script-locally.
>  Basically, I would assign env.run = run or env.run = local, depending on
> where I was deploying, perhaps in a task something like (warning: untested
> code):
>
> ```
> env.run = run
>
> @task
> def localhost():
>     env.run = local
>
> @task
> def do_something():
>     env.run('path/to/myscript.py')
> ```
>
> Then I would do invoke it like:
>
> ```
> fab local do_something
> ```
>
> This got smellier when I started rsyncing, since I had to write a
> local version and remote version of rsync.  Then when I started
> using `fabric.api.get`, I realized that I would have to write a API
> compatible version of `get` and `put` if I wanted to continue down this
> path.  That pushed me to find the better way described above.
>
> Hope that helps.
>
> -Todd
>
>
> On Thu, Jul 12, 2012 at 4:05 AM, Jorge Vargas <jorge.var...@gmail.com
> >wrote:
>
> > Hello,
> >
> > We are using fabric for development as well as deployment and I'm
> > wondering how people are doing command like this.
> >
> > @task
> > def load_fixtures():
> >     """Load initial data."""
> >     run("venv/bin/python data/fixtures.py")
> >
> > This code should work for both the developer machine (ie: run local) and
> > the deployment machine (ie: use run)
> >
> > So far what I have done is something like
> >
> > @task
> > def install_db(command=local):
> >     """@onetime install of the database"""
> >     with prefix("source venv/bin/activate"):
> >         command("python manage.py syncdb --migrate")
> >
> > However that's a bit of a problem as I can't call that command from fab
> > just from other fabric scripts.
> >
> > _______________________________________________
> > Fab-user mailing list
> > Fab-user@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/fab-user
> >
> >
>
>
> --
> Todd DeLuca
> http://todddeluca.com
> http://wall.hms.harvard.edu/
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.nongnu.org/archive/html/fab-user/attachments/20120712/c4a9c1af/attachment.html
> >
>
> ------------------------------
>
> _______________________________________________
> Fab-user mailing list
> Fab-user@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/fab-user
>
>
> End of Fab-user Digest, Vol 54, Issue 6
> ***************************************
>
_______________________________________________
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to