Fabric3

1.14.post1 · deprecated · verified Thu Apr 16

Fabric3 is a Python library and command-line tool designed for remote execution and deployment over SSH, forked from the original Fabric 1.x to provide compatibility with Python 3.4+. While it achieved Python 3 support, the official Fabric project (versions 2.x and above, and eventually 1.15.0) subsequently gained Python 3 compatibility and a redesigned API, rendering Fabric3 obsolete. It is now considered an unauthorized and deprecated fork.

Common errors

Warnings

Install

Imports

Quickstart

Create a file named `fabfile.py`. Define functions which will be executed as tasks. The `env` object is used for global configuration such as hosts and credentials. Tasks are executed from the command line using the `fab` command, e.g., `fab deploy`.

# fabfile.py
from fabric.api import run, env, sudo, put

# Configure hosts (replace with actual SSH connection details)
env.hosts = ['user@your_remote_host_ip']
env.password = 'your_ssh_password' # Or use SSH agent/key
env.warn_only = True # Don't abort on non-zero exit codes

def deploy():
    print(f"Deploying to {env.host_string}...")
    # Example: Update package lists and install nginx
    sudo('apt-get update && apt-get install -y nginx')
    run('service nginx start')
    print("Nginx installed and started.")

    # Example: Upload a local file
    local_path = '/tmp/test_file.txt'
    remote_path = '/tmp/remote_test.txt'
    with open(local_path, 'w') as f:
        f.write('Hello from Fabric3!')
    put(local_path, remote_path)
    run(f'cat {remote_path}')
    print("File uploaded and content verified.")

# To run this from your terminal:
# fab deploy

view raw JSON →