Skip to content

Instantly share code, notes, and snippets.

@Gabitronics
Gabitronics / notes.md
Created May 26, 2016 07:31 — forked from DavidWittman/notes.md
A Brief Introduction to Fabric

A Brief Introduction to Fabric

Fabric is a deployment management framework written in Python which makes remotely managing multiple servers incredibly easy. If you've ever had to issue a change to a group servers, this should look pretty familiar:

for s in $(cat servers.txt); do ssh $s service httpd graceful; done

Fabric improves on this process by providing a suite of functions to run commands on the servers, as well as a number of other features which just aren't possible in a simple for loop. While a working knowledge of Python is helpful when using Fabric, it certainly isn't necessary. This tutorial will cover the steps necessary to get started with the framework and introduce how it can be used to improve on administering groups of servers.

Fabric Cheatsheet

Cookbook

The fab command

Change host per task

from fabric.colors import green, red
from fabric.contrib.files import exists
from fabric.api import env, cd, run, sudo
from fabric.contrib.project import rsync_project
app_dir = '/apps/smsl'
git_repo = 'git@bitbucket.org:teamictlife/smsleopard.git'
env.use_ssh_config = True
user = 'focus'
@Gabitronics
Gabitronics / wordpress_fabfile.py
Created July 12, 2017 06:35 — forked from darwing1210/wordpress_fabfile.py
A Python Fabfile to deploy a wordpress site in a SSH
import os
from time import time
from fabric.api import sudo, run, task, env, cd, get, local
from fabric.context_managers import shell_env
env.hosts = ['yourhost']
env.user = 'yoursshuser'
env.password = 'yoursshpassword'
# env.key_filename = '~/yourkey.pem'
@Gabitronics
Gabitronics / ansible-summary.md
Created August 31, 2017 04:04 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)

Configuration file

intro_configuration.html

First one found from of