Created
April 8, 2014 16:06
-
-
Save awentzonline/10148726 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 fabric.api import * | |
| from fabric.operations import run | |
| env.user = 'remoteuser' | |
| env.webroot = '/usr/local/blah/htdocs' | |
| env['disable_known_hosts'] = True | |
| def production_provision(): | |
| _production_ansible_play() | |
| def production_install(): | |
| _production_ansible_play(tags='install') | |
| def production_config(): | |
| _production_ansible_play(tags='config') | |
| def production_push_code(): | |
| _production_ansible_play(tags='deploy') | |
| def _production_ansible_play(*args, **kwargs): | |
| kwargs['inventory'] = 'digitalocean' | |
| kwargs['user'] = 'ansible' | |
| kwargs['playbook'] = kwargs.get('playbook', 'site.yml') | |
| _ansible_play(*args, **kwargs) | |
| def vagrant_provision(): | |
| _vagrant_ansible_play() | |
| def vagrant_install(): | |
| _vagrant_ansible_play(tags='install') | |
| def vagrant_config(): | |
| _vagrant_ansible_play(tags='config') | |
| def vagrant_push_code(): | |
| _vagrant_ansible_play(tags='deploy') | |
| def _vagrant_ansible_play(*args, **kwargs): | |
| kwargs['inventory'] = 'vagrant' | |
| kwargs['user'] = 'vagrant' | |
| kwargs['playbook'] = 'site.yml' | |
| kwargs['extra'] = '%s --private-key=~/.vagrant.d/insecure_private_key' % kwargs.get('extra', '') | |
| _ansible_play(*args, **kwargs) | |
| def _ansible_play(inventory='', tags='', extra='', playbook='site.yml', user=''): | |
| if user: | |
| user = '-u %s' % user | |
| else: | |
| user = '' | |
| if tags: | |
| tags = '--tags=%s' % tags | |
| else: | |
| tags = '' | |
| cmd = 'ansible-playbook -i %s %s %s %s %s' % ( | |
| inventory, playbook, tags, user, extra | |
| ) | |
| with lcd('./ansible/'): | |
| local(cmd, capture=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment