Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Fabric demo
"""Fabric demo.
Setup Instructions:
pip install Fabric3
How to use:
fab --list
fab hello
fab provision
fab venv
from fabric.api import task, run, sudo, cd, env, get, put
import os
env.hosts = [""]
def hello():
"""Prints hello world message.
run("w > /tmp/w.txt")
def wc(filename):
put(filename, "/tmp")
run("wc /tmp/{} > /tmp/wc.txt".format(os.path.basename(filename)))
get("/tmp/wc.txt", "wc.txt")
def venv():
sudo("mkdir -p /usr/local/vikrant")
sudo("virtualenv /usr/local/vikrant/venv")
with cd("/usr/local/vikrant/venv"):
sudo("./bin/pip install Django")
def provision():
sudo("apt-get update")
sudo("apt-get install -y " + " ".join(APT_PACKAGES))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.