Add basic Ansible role layout for UWSGI, NGINX and supervisor setup.

This commit is contained in:
Dorian 2014-12-22 18:03:40 -05:00
parent 41a54c74e4
commit e8a243ef14
24 changed files with 187 additions and 140 deletions

44
README.md Normal file
View File

@ -0,0 +1,44 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the
role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in
defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables
that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as
well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be
set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for
users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
AGPL v3
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -1,7 +0,0 @@
:syntax on
:set number
:set textwidth=125
:set autoindent
:set shiftwidth=4
:set nobackup
:set nowritebackup

View File

@ -1,21 +0,0 @@
# Basic environmental
ENVIRONMENTAL_NAME = "Vagrant"
TESTING = False
DEBUG = True
# Password salts + secrets
PASSWORD_SALT = "secret"
SECRET_KEY = "development"
USER_REGISTRATION_INVITE_KEY = None
# Database
DATABASE_URI = "mysql+mysqlconnector://rookeries:penguin2013flight@localhost:3306/rookeries?charset=utf8"
# Mail server configuration
MAIL_SERVER = "localhost"
MAIL_PORT = 25
MAIL_USERNAME = "admin@rookeri.es"
MAIL_PASSWORD = "password"
MAIL_DEFAULT_SENDER = "admin@rookeri.es"
MAIL_USE_TLS = False
MAIL_USE_SSL = False

View File

@ -1,8 +0,0 @@
; Mailsink configuration
[program:mailsink]
command=/srv/www/virtualenvs/mail_server/bin/mailsinkd -w 8025 -s 25
stopsignal=TERM
stdout_logfile = /srv/www/logs/supervisor/mailsink-application.log
stdout_logfile_backups = 5
stderr_logfile=/srv/www/logs/supervisor/mailsink-error.log
stderr_logfile_backups=5

2
defaults/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# defaults file for ansible-nginx-uwsgi-supervisor

View File

@ -1,4 +0,0 @@
---
- include: deployment/rookeries_install.yaml
- include: deployment/uwsgi.yaml
- include: deployment/email_server.yaml

View File

@ -1,13 +0,0 @@
---
- hosts: all
sudo: yes
vars:
web_server_home: /srv/www
email_server_venv: "{{ web_server_home }}/virtualenvs/mail_server"
tasks:
- name: install mailsink test server into target virtualenv
pip: name=mailsink virtualenv={{ email_server_venv }} version=0.0.2
- name: restart up the mailsink program
supervisorctl: name=mailsink state=restarted config=/etc/supervisor/supervisor.conf

View File

@ -1,25 +0,0 @@
---
- hosts: all
sudo: yes
vars:
web_server_home: /srv/www
web_server_group: www-data
rookeries_venv: "{{ web_server_home }}/virtualenvs/rookeries"
rookeries_package: rookeries-0.4.0.tar.bz2
tasks:
- name: upload + extract rookeries package to web server home
unarchive: src=../../../{{ rookeries_package }} dest={{ web_server_home }}/
- name: install rookeries dependencies
pip: requirements=rookeries_webapp/requirements.txt virtualenv={{ rookeries_venv }} chdir={{ web_server_home }}
- name: install extra MySQL python connector dependency
pip: name=mysql-connector-python virtualenv={{ rookeries_venv }} version=1.1.6
extra_args='--allow-external mysql-connector-python --allow-unverified mysql-connector-python'
- name: fix permissions on extracted web app
file: path={{ web_server_home }}/rookeries_webapp owner={{ web_server_group }} group={{ web_server_group }}
state=directory recurse=yes
# TODO Step 4 - Setup environment variables on target system related to config.

2
handlers/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# handlers file for ansible-nginx-uwsgi-supervisor

128
meta/main.yml Normal file
View File

@ -0,0 +1,128 @@
---
galaxy_info:
author: your name
description:
company: your company (optional)
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
#
# Below are all platforms currently available. Just uncomment
# the ones that apply to your role. If you don't see your
# platform on this list, let us know and we'll get it added!
#
#platforms:
#- name: EL
# versions:
# - all
# - 5
# - 6
# - 7
#- name: GenericUNIX
# versions:
# - all
# - any
#- name: Fedora
# versions:
# - all
# - 16
# - 17
# - 18
# - 19
# - 20
#- name: SmartOS
# versions:
# - all
# - any
#- name: opensuse
# versions:
# - all
# - 12.1
# - 12.2
# - 12.3
# - 13.1
# - 13.2
#- name: Amazon
# versions:
# - all
# - 2013.03
# - 2013.09
#- name: GenericBSD
# versions:
# - all
# - any
#- name: FreeBSD
# versions:
# - all
# - 8.0
# - 8.1
# - 8.2
# - 8.3
# - 8.4
# - 9.0
# - 9.1
# - 9.1
# - 9.2
#- name: Ubuntu
# versions:
# - all
# - lucid
# - maverick
# - natty
# - oneiric
# - precise
# - quantal
# - raring
# - saucy
# - trusty
#- name: SLES
# versions:
# - all
# - 10SP3
# - 10SP4
# - 11
# - 11SP1
# - 11SP2
# - 11SP3
#- name: GenericLinux
# versions:
# - all
# - any
#- name: Debian
# versions:
# - all
# - etch
# - lenny
# - squeeze
# - wheezy
#
# Below are all categories currently available. Just as with
# the platforms above, uncomment those that apply to your role.
#
#categories:
#- cloud
#- cloud:ec2
#- cloud:gce
#- cloud:rax
#- clustering
#- database
#- database:nosql
#- database:sql
#- development
#- monitoring
#- networking
#- packaging
#- system
#- web
dependencies: []
# List your role dependencies here, one per line. Only
# dependencies available via galaxy should be listed here.
# Be sure to remove the '[]' above if you add dependencies
# to this list.

View File

@ -1,10 +0,0 @@
---
- include: pre_deployment/base_linux.yaml
- include: pre_deployment/python.yaml
- include: pre_deployment/mysql_db.yaml
- include: pre_deployment/nginx.yaml
- include: pre_deployment/supervisor.yaml
- include: pre_deployment/web_data_folders.yaml
- include: pre_deployment/nodejs.yaml
# TODO Add in globally defined values for webapp and virtualenv folders

View File

@ -1,10 +0,0 @@
---
- hosts: all
sudo: yes
tasks:
- name: install vim
apt: pkg=vim state=present
- name: configure vim
copy: src=../config/base/_vimrc dest=/home/vagrant/.vimrc

View File

@ -1,23 +0,0 @@
---
- hosts: all
sudo: yes
vars:
databases:
rookeries:
username: rookeries
password: system_admin
tasks:
- name: setup MySQL server + Python dependencies
apt: pkg={{ item }} state=present
with_items:
- mysql-server
- python-mysqldb
- name: setup MySQL databases for rookeries.
mysql_db: name={{ item.key }} state=present
with_dict: databases
- name: add MySQL database users for rookeries.
mysql_user: name={{ item.value.username }} password={{ item.value.password }} priv={{ item.key }}:ALL
with_dict: databases

View File

@ -1,19 +0,0 @@
---
- hosts: all
sudo: yes
tasks:
- name: install nodejs + npm dependencies
apt: pkg={{ item }} state=present
with_items:
- nodejs
- npm
- name: link nodejs binary correctly
file: src=/usr/bin/nodejs dest=/usr/bin/node state=link
- name: install coffeescript + less dependencies
npm: name={{ item }} global=yes state=present
with_items:
- coffee-script
- less

9
tasks/main.yml Normal file
View File

@ -0,0 +1,9 @@
---
# tasks file for ansible-nginx-uwsgi-supervisor
- include: python.yaml
- include: nginx.yaml
- include: supervisor.yaml
- include: web_data_folders.yaml
- include: uwsgi.yaml
# TODO Add in globally defined values for webapp and virtualenv folders

2
vars/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# vars file for ansible-nginx-uwsgi-supervisor