Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Ansible playbook template accompanying `flask-minimal` cookiecutter: deploys `flask-minimal` on an Ubuntu server

Notifications You must be signed in to change notification settings

candidtim/cookiecutter-flask-ansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

flask-ansible for flask-minimal

This is an Ansible playbook template accompanying flask-minimal cookiecutter template. It provides means to deploy flask-minimal application on an Ubuntu server.

Usage

Install cookiecutter and create a Flask application as per flask-minimal and build it (make sdist).

Create accompanying Ansible project from this template. Put it side-by-side with the Flask application created above (in the same root directory), and use same value for application package name, or you will need to change generated configuration accordingly:

cookiecutter https://github.com/candidtim/cookiecutter-flask-ansible.git

Install prerequisites as per generated README, and then run the application in the Virtualbox to test the generated configuration:

cd yourapplication-ansible
vagrant up

And open deployed application at http://127.0.0.1:8080/

When ready, configure inventory file and deploy to the server with:

ansible-playbook playbook.yml -i inventory.ini

Provided configuration

  • setuptools-ready Flask application installs into a dedicated virtualenv
  • runs in a uWSGI web server instance, installed into the same virtualenv
  • nginx server is used as a reverse proxy
  • all this is installed on an Ubuntu server, with a systemd service to run uWSGI instance
  • for tests only, Vagrant and Virtualbox are used

This implementation also assumes an Ubuntu development machine.

Opinionated, while still being minimal and production ready

This template is much more opinionated compared to the flask-minimal, but it still strives to be minimal and production-ready in its own way.

Deploying Flask application to production implies a lot of choice: OS version, WSGI implementation, reverse proxy HTTP server, logging configuration, maybe other ones. It is hard to provide a solution flexible enough to fit all possible needs: such an attempt will likely result in a very complex solution, and will still require customizations in most of real-world scenarios. More importantly, it is rarely required: for example, most projects won't require to be deployed to different WSGI servers at the same time, but stick to one of them.

This is why this project, instead, provides a simple solution, which is ready for use, but makes a couple of choices. You can use this in two cases:

  • if choices made here fit your needs
  • or as an example to build your own configuration

Contributions

... are welcome! Feel free to create a pull request to fix bugs, keep up to date, or propose a feature.

About

Ansible playbook template accompanying `flask-minimal` cookiecutter: deploys `flask-minimal` on an Ubuntu server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages