[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] How do I run a function only once, locally, after the oth
From: |
Jeff Forcier |
Subject: |
Re: [Fab-user] How do I run a function only once, locally, after the other functions complete? |
Date: |
Thu, 8 Aug 2013 16:18:01 -0700 |
Hi Kyle,
Sorry for the tardy reply - but you struck on what I was going to
suggest :) this is one reason why execute() exists, lets you take
explicit control of the top level execution context (re: what code
runs against what targets). Hope that approach works OK for you!
Best,
Jeff
On Thu, Aug 8, 2013 at 11:43 AM, Kyle Reynolds
<address@hidden> wrote:
> I solved it like so:
>
> #-------------
> from fabric.api import *
>
> env.user = call("whoami")
>
> # assign CLI -H args to role 'current'
> env.roledefs ={
> 'current': env.hosts
> }
>
> # clear env.hosts so commands default to localhost
> env.hosts = ''
>
> # function to run on remote servers
> def testit():
> run('hostname')
>
> # function to run once, locally
> def runlocal():
> local('touch "`date`"')
>
> def bigtest():
> execute(testit, role='current')
> runlocal()
>
> --
>
> fab -H server1,server2,server3 bigtest
>
> ...runs 'testit' on each server listed on the commandline, yet only runs
> 'runlocal' once, last.
>
>
>
>
> On Wed, Aug 7, 2013 at 2:10 PM, Kyle Reynolds <address@hidden>
> wrote:
>>
>> I am using fabric to pull configuration files to a local directory, and
>> then once I have all of the files local, I want to run an md5 checksum to
>> check consistency. The problem I'm having is figuring out how to run the
>> final function, only ONCE, locally, AFTER all of the files have been pulled
>> down by another function.
>>
>> I have looked into the @run_once decorator, but I need this function to
>> run after everything, not once on the first run.
>>
>> any ideas or suggestions?
>>
>> Thanks!
>>
>>
>
>
>
> --
> Sent via International Space Station by way of my Top Secret decoder ring
> --
>
> Kyle Reynolds
> --------------------------------------------------------------
> http://www.mythictechnologies.com
> --------------------------------------------------------------
> address@hidden
> --------------------------------------------------------------
> Follow me on Twitter! https://twitter.com/kyle_reynolds
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/fab-user
>
--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org