Python

Ansible Python Site Role

Build Status License Role Name Release Version Downloads

This role will create a site in Nginx for running applications written in Python. It supports either Python 2 or 3.

Requirements

This role takes advantage of Linux filesystem ACLs and a group called "web-admin" for granting access to particular directories. You can either configure those steps manually or install the bbatsche.Base role.

Role Variables

  • domain — Site domain to be created.
  • python_version — Python version to use with this site. Default is "3"
  • env_name — Whether this server is a "development", "production", or other type of server. Development servers will use the global Python binaries and packages, other types will use a virtualenv setup in the site directory. Default is "dev"
  • copy_wsgi — Whether to copy a stub passenger_wsgi.py file to the site, useful for testing. Default is no
  • http_root — Directory all site directories will be created under. Default is "/srv/http"
  • nginx_configs — Additional config files to add to the end of the domain's server block. These files should be copied to /etc/nginx/conf.d. Default is the domain's Python configuration: [ python-{{ domain }}.conf ]

Dependencies

This role depends on bbatsche.Nginx. You must install that role first using:

ansible-galaxy install bbatsche.Nginx

Example Playbook

- hosts: servers
  roles:
     - { role: bbatsche.Python, domain: my-python-site.dev }

License

MIT

Testing

Included with this role is a set of specs for testing each task individually or as a whole. To run these tests you will first need to have Vagrant and VirtualBox installed. The spec files are written using Serverspec so you will need Ruby and Bundler.

To run the full suite of specs:

$ gem install bundler
$ bundle install
$ rake

The spec suite will target Ubuntu Trusty Tahr (14.04), Xenial Xerus (16.04), and Bionic Bever (18.04).

To see the available rake tasks (and specs):

$ rake -T

These specs are not meant to test for idempotence. They are meant to check that the specified tasks perform their expected steps. Idempotency is tested independently via integration testing.

About

Create an Nginx site running either Python 2.7 or 3.4 through Phusion Passenger

Install
ansible-galaxy install bbatsche/Ansible-Python-Site-Role
GitHub repository
License
mit
Downloads
109