Code Monkey home page Code Monkey logo

tequila-fab's Introduction

tequila-fab

This is a Python package providing a library that can be imported from fabric3 scripts to provide common implementations of typical tasks for projects that are using tequila for provisioning and deploy.

License

This Ansible role is released under the BSD License. See the LICENSE file for more details.

Releases

We attempt to not make changes that break backward-compatibility. Nonetheless, you should always use a pinned version of this repo to be safe. Check the release history before upgrading for any notes or warnings.

Contributing

If you think you've found a bug or are interested in contributing to this project, check out tequila-fab on Github.

Development sponsored by Caktus Consulting Group, LLC.

Installation

pip install into your virtualenv:

$ pip install git+https://github.com/caktus/[email protected]#egg=tequila-fab

Usage

The simplest case is to just import everything from tequila_fab at the top of your fabfile.py:

# fabfile.py

from tequila_fab import *

Then write some tasks to select environments, e.g.:

from fabric.api import env, task

@task
def staging():
    """
    Usage: fab staging <tasks>
    """
    env.environment = 'staging'

These just need to set env.environment to the name of one of your tequila environments.

Now users can use the tasks as documented in the reference below. You'd likely start with:

$ fab install_roles
$ fab <ENVNAME> bootstrap

for new servers. Then:

$ fab <ENVNAME> deploy:playbook=site.yml
$ fab <ENVNAME> create_superuser:[email protected]

Most of these tasks end up invoking Ansible playbooks from tequila, so be sure to see the docs there for more information, and of course your own playbooks and configuration in your project's deployment directory.

Task reference

(In alphabetical order.)

bootstrap

Does the simplest possible install of Python v2 so that Ansible can run from then on. Use when the target servers might not even have Python installed.:

$ fab <ENVNAME> bootstrap

check_role_versions

Check that the roles required in requirements.yml are all installed and at the right version, and fail if not.

This gets run automatically before a deploy or bootstrap, so won't often need to be run by itself.:

$ fab check_role_versions

create_superuser

Create a superuser with no password (there's no way to pass a new password to the createpassword command non-interactively). Use password reset after creating the user.:

$ fab <ENVNAME> create_superuser:<USERNAME>

For example:

$ fab staging create_superuser:[email protected]

deploy

Run an ansible deploy for an environment.

By default, runs the playbook web and deploys the default branch for the specified environment. You can override either of those by passing playbook or branch options. Do not include .yml in the playbook name.

Warning

By default this runs the playbook web which does not do a complete provision (it just updates the web servers). For initial deploys, you probably need to run the playbook site. After that, you can just use the default if only the web servers need updating.

Note

Should we change this to default to the site.yml playbook, since that's always safe?

You can also set/override any Ansible variable by passing the extra_vars option. Here's the usage:

$ fab <ENV> deploy[:playbook=NNNN][:extra_vars=aaa=1,bbb=2][:branch=xxx]

Some examples:

$ fab staging deploy
$ fab staging deploy:playbook=site
$ fab staging deploy:branch=PRJ-9999
$ fab staging deploy:playbook=site:extra_vars=gunicorn_num_workers=8

install_roles

Run Ansible galaxy's role installer for the requirements in deployment/requirements.yml.

Warning

Ansible galaxy does not check version numbers. It only installs roles that are not installed already. So running install_roles is not enough to ensure your roles are up to date.

You can run fab check_role_versions to see if versions are up to date.

deploy and bootstrap also check and refuse to run if versions are wrong.

Note

Ansible galaxy always installs roles into the first directory on your roles_path by default. Maybe install_roles ought to override that on the command line and always install to deployment/roles?

tequila-fab's People

Contributors

dpoirier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.