fabric
Python SSH automation and deployment tool
TLDR
Run command on remote host
SYNOPSIS
fab [options] [task[:arg,...]]...
DESCRIPTION
Fabric is a Python library and command-line tool for executing shell commands on remote servers over SSH. It simplifies deployment, system administration, and automation tasks.
Tasks are defined in a fabfile.py using Python. Fabric 2.x provides a cleaner API than version 1.x, with Connection objects and a simpler task decorator.
PARAMETERS
-H, --hosts hosts
Comma-separated host list.-i key
SSH identity file.-u, --user user
SSH username.-l, --list
List available tasks.-p, --password
Prompt for SSH password.-d task
Show task docstring.-- command
Run shell command directly.-c, --config file
Config file path.-r, --roles roles
Roles to operate on.
FABFILE EXAMPLE
@task
def deploy(c):
c.run("git pull")
c.run("pip install -r requirements.txt")
c.run("systemctl restart myapp")
@task
def uptime(c):
c.run("uptime")
CAVEATS
Version 2.x is significantly different from 1.x. Requires SSH access. Python 3 required for Fabric 2+. Complex deployments may benefit from Ansible or similar tools.
HISTORY
Fabric was created by Jeff Forcier in 2009 as a simpler alternative to Capistrano for Python deployments. Version 2.0, released in 2018, was a complete rewrite with a modernized API.
