Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fabric.api import *
- env.user='ubuntu'
- env.hosts = ['xyz.com','def.com', 'ghi.com', 'lol.com', 'rofl.com']
- env.roledefs['appagent'] = ['ghi.com', 'lol.com', 'rofl.com']
- env.password='<provide_your_ssh_connection_password>'
- env.parallel = True
- def host():
- run('uname -a')
- hn = run('hostname')
- print "Hostname is : " , hn
- @roles('appagent')
- @with_settings(warn_only=True)
- def install(name='apache2'):
- installed = run('service --status-all | grep -c ' + name)
- if int(installed) < 1:
- sudo('apt-get update')
- sudo('apt-get install -y ' + name)
- sudo('service ' + name + ' restart')
- else:
- print name + " is already installed, checking if its running or not"
- running = run('ps -A | grep -c ' + name)
- if int(running) == 0:
- print "starting " + name
- sudo('service ' + name + ' restart')
- else:
- print name + " already in running state"
Add Comment
Please, Sign In to add comment