Skip to content

Instantly share code, notes, and snippets.

@bassdread
Created January 2, 2013 21:17
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 bassdread/4438138 to your computer and use it in GitHub Desktop.
Save bassdread/4438138 to your computer and use it in GitHub Desktop.
from fabric.api import *
import fabric
env.hosts=["ec2-23-22-191-90.compute-1.amazonaws.com"]
env.user="ec2-user"
def hostname_check(): # hostname_check is just a task name, replace with anything
run("hostname")
def install_agent(key, url):
f = open('config.cfg', 'r')
config_file = f.read()
f.close()
config_file = config_file % (url, key)
f = open('populated_config.cfg', 'w')
f.write(config_file)
f.close()
f = open('serverdensity.repo', 'r')
repo = f.read()
f.close()
sudo("rpm --import https://www.serverdensity.com/downloads/boxedice-public.key")
run("wget https://www.serverdensity.com/downloads/boxedice-public.key")
sudo("rpm --import boxedice-public.key")
sudo("echo '%s' >> /etc/yum.repos.d/serverdensity.repo" % (repo))
sudo('yum install -y sd-agent')
fabric.operations.put('./populated_config.cfg', '/etc/sd-agent/', use_sudo=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment