Deploys a Python based application in 12 factor fashion.
- Creates a system user to own the application.
- Each deployment is isolated in its own directory with its own virtualenv.
- Makes secrets available in
$APP_DEPLOYMENT_DIR/secrets/env
. - Application configuration and installation is done first, before linking (making the deployment active).
- Old deployments are removed.
- (Optionally) installs a supervisor configuration.
- (Optionally) installs a crontab.
This role is influenced by Ansistrano.
Include these roles in your requirements.yml.
Use the role in your playbook:
---
- name: install a python app
roles:
- role: gsa.datagov-deploy-python-app
vars:
python_app_user: myapp
The OS user to create and install the app under. This is also used as the application name.
The git URL to your app repository.
The tag, branch, or commit to clone your application from.
The string to use for the deployment version. This is usually a timestamp so each deployment is uniq. It's important that deploy versions sort chronologically so that cleanup removes the oldest deploys by sorting by the deployment version.
Directory to create for the Python app user's home directory. This is where application deployments will be installed.
The version of Python to install.
The relative path to your requirements.txt from your application source.
The number of previous deployments to retain. Set to 0 to retain all old deployments.
List of OS packages that are needed by your application.
List of supervisor programs to restart after a deployment.
Pipenv creates a virtualenv for you and installs the python dependencies.
$ pipenv install --dev
Then you can run commands with pipenv.
$ pipenv run molecule converge
Or, you can activate the virtualenv in your shell so you don't have to run pipenv all the time.
$ pipenv shell
Run the tests with molecule.
$ pipenv run molecule test --all
If you're new to molecule, see our wiki for a quick primer.
See CONTRIBUTING for additional information.
This project is in the worldwide public domain. As stated in CONTRIBUTING:
This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.