Created
March 30, 2017 05:49
-
-
Save joejulian/a73eedb40c55e35a5a69f921b23214ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
import sys | |
def sleepex(data): | |
# Set some defaults in case this filter is called without | |
# being in a loop | |
delay=1.25 # seconds | |
attempt=1 | |
if 'delay' in data.keys(): | |
delay=data['delay'] | |
if 'attempts' in data.keys(): | |
attempt=data['attempts'] | |
# Sleep for delay to the power of attempt. This produces | |
# an exponential backoff. Subtract 1 delay that will be | |
# done by ansible itself. | |
sleep(delay**attempt-delay) | |
# Always return True as this isn't actually testing anything | |
return True | |
class FilterModule(object): | |
''' Query filter ''' | |
def filters(self): | |
return { | |
'sleepex': sleepex | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment