fabric-digitalocean

Visit site

A collection of tools aiming to make it easy to use Fabric and DigitalOcean together.

fabric-digitalocean is a collection of tools aiming to make it easy to use Fabric and DigitalOcean together.

Installation

pip install fabric-digitalocean

Usage

With fabric-digitalocean, you can decorate Fabric tasks to run on a set of DigitalOcean Droplet. The @droplets decorator can take a list of Droplet IDs, a tag, or a region as an argument. If you use a tag or region, it will be expanded to a list of all Droplets with that tag applied or in that region. They can also be used together.

The environmental variable FABRIC_DIGITALOCEAN_TOKEN must contain a DigitalOcean API token.

See below for an example:

from fabric.api import task, run
from fabric_digitalocean.decorators import droplets


@task
@droplets(ids=[8043964, 7997777])
def task_by_ids():
    run('hostname')
    run('uptime')


@task
@droplets(tag='demo')
def task_by_tag():
    run('hostname')
    run('uptime')


@task
@droplets(region='nyc3')
def task_by_region():
    run('hostname')
    run('uptime')


@task
@droplets(region='nyc2', tag='demo')
def task_by_both():
    run('hostname')
    run('uptime')
Was this helpful?
 
1 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

from fabric.api import task, run from fabric_digitalocean.decorators import droplets

@task @droplets(ids=[8043964, 7997777]) def task_by_ids(): run(‘hostname’) run(‘uptime’)

@task @droplets(tag=‘demo’) def task_by_tag(): run(‘hostname’) run(‘uptime’)

@task @droplets(region=‘nyc3’) def task_by_region(): run(‘hostname’) run(‘uptime’)

@task @droplets(region=‘nyc2’, tag=‘demo’) def task_by_both(): run(‘hostname’) run(‘uptime’)

Publish your Tool on Community

Have you created an Integration, API Wrapper, Service, or other Tool that helps developers build on DigitalOcean? Help users find it by listing it in Community Tools.

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.