Skip to content

Instantly share code, notes, and snippets.

@felipellrocha
Created March 8, 2015 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipellrocha/ea407a31554db3badbbe to your computer and use it in GitHub Desktop.
Save felipellrocha/ea407a31554db3badbbe to your computer and use it in GitHub Desktop.
import logging
from salt.exceptions import CommandExecutionError
log = logging.getLogger(__name__)
__outputter__ = {
'deploy': 'highstate'
}
SERVICES = [
'uwsgi',
'celeryd'
]
def deploy():
_id = __grains__['id']
directories = __pillar__['directories']
main_user = __pillar__['main_user']
ret = {'Machine': _id, 'changes': [], 'changed': False}
for service in SERVICES:
if (__salt__['service.available'](service)):
try:
ret['changed'] = True
ret['result'] = True
__salt__['git.pull'](directories['src'], user=main_user)
__salt__['service.restart'](service)
ret['changes'].append({'name': service, 'updated': True})
except CommandExecutionError as e:
ret['changed'] = True
ret['result'] = False
ret['changes'].append({'name': service, 'updated': False})
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment