Setup and pre-deployment Ansible playbook.

Fix deploy to vagrant tasks.
Move configuration files around for Ansible.
This commit is contained in:
Dorian 2014-11-19 16:27:37 -05:00
parent 0b291af9e7
commit d2db632bb8
13 changed files with 120 additions and 50 deletions

7
config/base/_vimrc Normal file
View File

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

View File

@ -0,0 +1,14 @@
server {
server_name localhost;
location /static/ {
alias /var/www/rookeries/static/;
}
location / { try_files $uri @yourapplication; }
location @yourapplication {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8001;
}
}

6
config/requirements.txt Normal file
View File

@ -0,0 +1,6 @@
--allow-external mysql-connector-python
--allow-unverified mysql-connector-python
mysql-connector-python==1.1.6
uwsgi==2.0
mailsink==0.0.2

View File

@ -0,0 +1,21 @@
# 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

@ -0,0 +1,5 @@
[uwsgi]
socket = :8001
log = /tmp/rookeries-uwsgi.log
master = true
module = rookeries:app

View File

@ -1,6 +1,4 @@
---
- hosts: all
sudo: yes
tasks:
# TODO Include all necessary deployment playbooks
- include: deployment/rookeries_install.yaml
- include: deployment/email_server.yaml
- include: deployment/uwsgi.yaml

View File

@ -4,5 +4,5 @@
tasks:
# TODO PIP install mailsink into a virtualenv somewhere
- name: Install fake SMTP server for email development.
pip: name=mailsink use_mirrors=no
# - name: Install fake SMTP server for email development.
# pip: name=mailsink use_mirrors=no

View File

@ -1,6 +1,6 @@
---
- hosts: all
sudo: yes
tasks:
# TODO Include all necessary playbooks
- include: pre_deployment/base_linux.yaml
- include: pre_deployment/python.yaml
- include: pre_deployment/mysql_db.yaml
- include: pre_deployment/nodejs.yaml
- include: pre_deployment/nginx.yaml

View File

@ -3,10 +3,11 @@
sudo: yes
tasks:
- name: Update and upgrade system
apt: update_cache=yes upgrade=full
- name: Install vim
apt: pkg=vim update_cache=yes state=present
apt: pkg=vim state=present
- name: Configure vim
copy: src=config/base/_vimrc dest=/home/vagrant/.vimrc
# TODO Add update of apt cache + any extra repo setup here.
copy: src=../config/base/_vimrc dest=/home/vagrant/.vimrc

View File

@ -1,18 +1,23 @@
---
- hosts: all
sudo: yes
vars:
databases:
rookeries:
username: rookeries
password: system_admin
tasks:
# Setup MySQL dependencies.
# TODO Extract all variables into an easy to configure file.
- name: Install MySQL 5x server
apt: pkg=mysql-server update_cache=no state=present
- name: Setup MySQL 5 server + Python dependencies
apt: pkg={{ item }} state=present
with_items:
- mysql-server
- python-mysqldb
- name: Install mysqldb is installed.
apt: pkg=python-mysqldb update_cache=no state=present
- name: Setup MySQL databases for rookeries.
mysql_db: name={{ item.key }} state=present
with_dict: databases
- name: Setup MySQL database for rookeries.
mysql_db: name=rookeries state=present
- name: Setup MySQL database user for rookeries.
mysql_user: name=rookeries password=system_admin priv=rookeries:ALL
- name: Setup 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,20 +1,20 @@
---
- hosts: all
sudo: yes
vars:
rookeries_nginx_conf: rookeries-uwsgi.conf
tasks:
# Next setup our webserver.
# TODO Extract variables into a single easy to configure place.
- name: Install nginx
apt: pkg=nginx-full update_cache=yes state=present
- name: Setup nginx webserver
apt: pkg=nginx-full state=present
- name: Configure nginx
copy: src=config/nginx/rookeries-uwsgi.conf dest=/etc/nginx/sites-available
copy: src=../config/nginx/{{ rookeries_nginx_conf }} dest=/etc/nginx/sites-available
- name: Link the rookeries uwsgi file
file: state=link
src=/etc/nginx/sites-available/rookeries-uwsgi.conf
path=/etc/nginx/sites-enabled/rookeries-uwsgi.conf
src=/etc/nginx/sites-available/{{ rookeries_nginx_conf }}
path=/etc/nginx/sites-enabled/{{ rookeries_nginx_conf }}
- name: Unlink the default page
file: state=absent path=/etc/nginx/sites-enabled/default
@ -22,8 +22,9 @@
- name: Run nginx service
command: service nginx restart
- name: Setup webapp deployment folder with the correct permissions
file: path=/var/www state=directory owner=vagrant group=www-data mode=0774
- name: Add vagrant user to www-data
user: name=vagrant append=yes groups=www-data
# TODO Verify if still required for pip package deployment
# - name: Setup webapp deployment folder with the correct permissions
# file: path=/var/www state=directory owner=vagrant group=www-data mode=0774
#
# - name: Add vagrant user to www-data
# user: name=vagrant append=yes groups=www-data

View File

@ -3,4 +3,14 @@
sudo: yes
tasks:
# TODO Install nodejs + coffeescript dependencies
- name: Setup nodejs + npm dependencies
apt: pkg={{ item }} state=present
with_items:
- nodejs
- npm
- name: Setup coffeescript + lessc dependency
npm: name={{ item }} global=yes state=present
with_items:
- coffee-script
- less

View File

@ -3,18 +3,20 @@
sudo: yes
tasks:
# Setup Python dependencies.
- name: Python Development
apt: pkg=python-dev update_cache=no state=present
- name: Bootstrap Python SetupTools
apt: pkg=python-setuptools update_cache=no state=present
- name: Setup Python setuptools dependencies
apt: pkg={{ item }} state=present
with_items:
- python-dev
- python-setuptools
- name: Bootstrap PIP using Setuptools
easy_install: pkg=pip state=present
easy_install: name=pip
- name: Install Python virtualenvwrapper
pip: name=virtualenvwrapper use_mirrors=no
- name: Basic Python dependencies
pip: name={{ item }} use_mirrors=no
with_items:
- virtualenv
- virtualenvwrapper
- name: Configure Bash to use virtualenvwrapper
- name: Add virtualenvwrapper to bashrc
lineinfile: dest=/home/vagrant/.bashrc line="source virtualenvwrapper.sh"