Skip to content

Instantly share code, notes, and snippets.

@kszarek
Created October 22, 2014 09:26
Show Gist options
  • Save kszarek/28e4569c9f6e26ace008 to your computer and use it in GitHub Desktop.
Save kszarek/28e4569c9f6e26ace008 to your computer and use it in GitHub Desktop.
Custom task for fabric
class CustomTask(Task):
def __init__(self, func, myarg, *args, **kwargs):
super(CustomTask, self).__init__(*args, **kwargs)
self.func = func
self.myarg = myarg
if env.hosts == []:
logger.debug("env.hosts is empty")
# if hasattr(env, 'env_name'):
logger.debug("Found env_name in env")
set_dynamic_inventory()
def run(self, *args, **kwargs):
return self.func(*args, **kwargs)
@task(task_class=CustomTask, myarg='value')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment