Created
August 10, 2012 21:36
-
-
Save alq666/3318245 to your computer and use it in GitHub Desktop.
Testing the fabric integration
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
easy_install fabric | |
python -c "import fabric; print fabric" | |
# <module 'fabric' from '.../python2.7/site-packages/Fabric-1.4.3-py2.7.egg/fabric/__init__.pyc'> | |
cd dogapi | |
fab -f examples/fabfile.py sweet_task:"yay!" | |
# My sweet task always runs properly. | |
# | |
# Done. | |
fab -f examples/fabfile.py boring_task:"oh noes" | |
fab -f examples/fabfile.py boring_task:"oh noes" | |
# My boring task is designed to fail. | |
# Traceback (most recent call last): | |
# ... | |
# File "build/bdist.macosx-10.8-intel/egg/dogapi/fab.py", line 72, in wrapper | |
# Exception: failure!!! |
Indeed the first @task gets discarded. I'm tracing it in the debugger.
@task sorry this was not intended to notify you, it's a fabric construct...
Fixed in 1.0.11 (being tested right now).
Commit details: DataDog/dogapi@484850b
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a snippet of my fabfile:
import os, sys
from fabric.api import *
from fabric.colors import *
from dogapi.fab import setup, notify
setup(api_key = "YOUR API KEY HERE")
sys.path.insert( 0, os.path.abspath( os.path.join( os.path.realpath( os.path.curdir ), '../' ) ) )
from lib.server_ip_map import ServerIpMap, ServerIpMapException
from lib.modenv_parser import ModEnvParser
sim = ServerIpMap('/srv/sys_restore/etc/server_ip_mappings.txt')
env.user = 'deployer'
env.roledefs = {'staging': sim.get_group('www-staging', 'external_ip'),
'qa': sim.get_group('www-qa', 'external_ip'),
'sandbox': sim.get_group('www-sandbox', 'external_ip'),
'assets-staging': sim.get_group('assets-staging', 'external_ip'),
'assets-qa': sim.get_group('assets-qa', 'external_ip'),
'assets-live': sim.get_group('assets-live', 'external_ip'),
'assets': sim.get_group('assets', 'external_ip'),
'live': sim.get_group('www-live', 'external_ip')}
env.roledefs['staging'].extend(env.roledefs['assets-staging'])
env.roledefs['qa'].extend(env.roledefs['assets-qa'])
env.roledefs['live'].extend(env.roledefs['assets-live'])
env.roledefs['staging'].reverse()
env.roledefs['qa'].reverse()
env.roledefs['live'].reverse()
env.parallel = 'True'
env.forward_agent = 'True'
def get_env():
def clean_modules(mods):
""" converts and cleans modules list based on which instance we're on. """
@notify
@task
def update_sys_restore():
run('cd /srv/sys_restore && git pull')
print "\n"
@task
def host_type():
run('uname -a')
print "\n"