Skip to main content

A collection of fabric tasks

Project description

This is a set of reusable fabric tasks. It uses the new-style task system of fabric >= 1.2

Usage

  • Add dploi-fabric to your buildout environment (preferably in development_local.cfg, the servers have no use for it).

  • Create a fabfile.py as normal.

  • Pick and choose the modules and import them in the fabfile.py, e.g.:

    from fabric.decorators import task
    
    from dploi_fabric.db import pg # if project uses mysql, import "mysql" instead
    from dploi_fabric import supervisor, nginx
    from dploi_fabric import git, utils, buildout, south, django_utils, project
    
    from dploi_fabric.conf import load_settings
    
    @task
    def dev():
        load_settings('dev')
    
    @task
    def stage():
        load_settings('stage')
    
    @task
    def live():
        load_settings('live')
    
    @task
    def deploy():
        pg.dump.run()
        git.update()
        buildout.run()
        south.migrate.run()
        django_utils.collectstatic()
        supervisor.restart()
        supervisor.status()
        nginx.update_config_file()
  • in the project root, create a file deployment.py following this template:

    project_name = 'awesome_new_website'
    
    settings = {
        'dev': {
            'hosts': ['yourserver.com'],
            'path': '/home/awesome_new_website-dev/app/',
            'user': 'awesome_new_website-dev',
            'buildout_cfg': 'server_dev.cfg',
            'repo': 'git@github.com:youruser/awesome_new_website.git',
            'branch': 'master',
            'backup_dir': '/home/awesome_new_website-dev/tmp/', # Used for mysql/psql dumps
            'db_name': 'awesome_new_website-dev',
            'db_username': 'awesome_new_website-dev',
            'domains': ['sitename-dev.agency.com', 'www.sitename.com'],
            'domains_redirect': [
                {'domain': 'sitename.com', 'destination_domain': 'www.sitename.com'},
            ],
            'ssl': True,
            'ssl_key_path': '../config/ssl.key', # This must be uploaded manually, possibly by a task in the future
            'ssl_cert_path': '../config/ssl.crt', # This must be uploaded manually, possibly by a task in the future
            'basic_auth': False,
            'basic_auth_path': '../config/htpasswd', # This must be uploaded manually, possibly by a task in the future
        },
    }

    add settings for stage/live as needed.

  • call bin/fab --list for a list of commands

Configuration file (config.ini)

Remember to add config.ini, example:

[static]

/media/ = py_src/project/media/

and/or

[static]

/static/ = %(static_files)s

Other options

[checkout]

tool = buildout (default)

tool = virtualenv

[celery] (if the section is present, celery is enabled)

[django]

base = .

base = project/

base = py_src/project (doesnt work with buildout yet, as it would try to access py_src/project/bin/django)

append_settings = true

append_settings = false

[static]

(see above)

/url-path/ = rel-path-filesystem/

[sendfile] /protected/media/ = ../upload/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dploi-fabric-0.1.18.tar.gz (16.2 kB view details)

Uploaded Source

File details

Details for the file dploi-fabric-0.1.18.tar.gz.

File metadata

File hashes

Hashes for dploi-fabric-0.1.18.tar.gz
Algorithm Hash digest
SHA256 aaa34eb2db43e0b6835855b5e58597767a4ae9078fac493fb3da6d23427a1626
MD5 440de5e9e50aaa98bb3b4c389e63b0fe
BLAKE2b-256 ddf6951cbfff56f56a98afea5f5ae3da6c48c5ff574fbdc0f34197bc695b755c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page