fab-user
[Top][All Lists]
Advanced

[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: Kyle Reynolds
Subject: Re: [Fab-user] How do I run a function only once, locally, after the other functions complete?
Date: Thu, 8 Aug 2013 13:43:03 -0500

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 


reply via email to

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