Migrate variables into a separate module.

Turn included playbooks into pure task modules.
This commit is contained in:
Dorian 2015-01-07 18:23:43 -05:00
parent dcabd1a549
commit 8892de863c
6 changed files with 110 additions and 102 deletions

View File

@ -5,5 +5,3 @@
- include: supervisor.yaml
- include: web_data_folders.yaml
- include: uwsgi.yaml
# TODO Add in globally defined values for webapp and virtualenv folders

View File

@ -1,12 +1,7 @@
---
- sudo: yes
vars:
rookeries_nginx_conf: rookeries-uwsgi_nginx.conf
web_server_group: www-data
tasks:
- name: install nginx webserver
apt: pkg=nginx-full state=present
sudo: yes
- name: configure nginx
copy: src=../config/nginx/{{ rookeries_nginx_conf }} dest=/etc/nginx/sites-available
@ -15,12 +10,15 @@
file: state=link
src=/etc/nginx/sites-available/{{ rookeries_nginx_conf }}
path=/etc/nginx/sites-enabled/{{ rookeries_nginx_conf }}
sudo: yes
- name: disable the default page configuration
file: state=absent path=/etc/nginx/sites-enabled/default
sudo: yes
- name: restart nginx
service: name=nginx state=restarted
sudo: yes
- name: set permissions on nginx config + log directories
file: path={{ item }} state=directory
@ -30,6 +28,7 @@
- /etc/nginx
- /etc/nginx/sites-available
- /etc/nginx/sites-enabled
sudo: yes
- name: set permissions on nginx logs
file: path=/var/log/nginx/{{ item }} state=file
@ -37,3 +36,4 @@
with_items:
- access.log
- error.log
sudo: yes

View File

@ -1,14 +1,7 @@
---
- sudo: yes
vars:
web_server_group: www-data
supervisor_configs:
- mailsink_supervisor.conf
- rookeries_supervisor.conf
tasks:
- name: install supervisord
apt: name=supervisor state=present
sudo: yes
- name: set permissions on supervisor config and log directories
file: path={{ item }} group={{ web_server_group }} state=directory mode=0755
@ -16,14 +9,17 @@
- /etc/supervisor
- /etc/supervisor/conf.d
- /var/log/supervisor
sudo: yes
- name: modify supervisor configuration
ini_file: dest=/etc/supervisor/supervisord.conf section=unix_http_server
option={{ item.key }} value={{ item.value }}
with_dict:
chmod: "0770"
chown: root:www-data
chown: root:{{ web_server_group }}
sudo: yes
- name: upload rookeries supervisor configuration to web server home
copy: src=../config/supervisor/{{ item }} dest=/etc/supervisor/conf.d
with_items: supervisor_configs
sudo: yes

View File

@ -1,17 +1,12 @@
---
- vars:
web_server_home: /srv/www
web_server_group: www-data
uwsgi_venv: "{{ web_server_home }}/virtualenvs/uwsgi"
uwsgi_config: "{{ web_server_home }}/config/uwsgi"
rookeries_uwsgi_ini: rookeries-uwsgi.ini
tasks:
- name: install uwsgi server
pip: name=uwsgi virtualenv={{ uwsgi_venv }} version=2.0
sudo: yes
- name: upload rookeries configuration
copy: src=../config/uwsgi/{{ rookeries_uwsgi_ini }} dest={{ uwsgi_config }}
sudo: yes
- name: restart uwsgi server
supervisorctl: name=uwsgi state=restarted config=/etc/supervisor/supervisor.conf
sudo: yes

View File

@ -1,13 +1,7 @@
---
- sudo: yes
vars:
user: "{{ ansible_env.SUDO_USER }}"
web_app_home: /srv/www
web_server_group: www-data
tasks:
- name: setup webapp deployment folder with the correct permissions
file: path={{ web_app_home }} state=directory owner={{ web_server_group }} group=www-data mode=0774
sudo: yes
- name: setup webapp deployment configuration + log folders with the correct permissions
file: path={{ web_app_home }}/{{ item }} state=directory
@ -17,6 +11,7 @@
- config/uwsgi
- logs
- virtualenvs
sudo: yes
- name: setup webapp deployment configuration + log folders with the correct permissions
file: state=link
@ -28,6 +23,8 @@
/etc/supervisor: config/supervisor
/var/log/nginx: logs/nginx
/var/log/supervisor: logs/supervisor
sudo: yes
- name: add user to www-data
user: name={{ user }} append=yes groups={{ web_server_group }}
sudo: yes

View File

@ -1,2 +1,24 @@
---
# vars file for ansible-nginx-uwsgi-supervisor
# TODO Make more configurable and flexible
# NGINX
rookeries_nginx_conf: rookeries-uwsgi_nginx.conf
web_server_group: www-data
# Supervisor
# TODO Allow for multiple supervisord configurations
supervisor_configs:
# - mailsink_supervisor.conf
- rookeries_supervisor.conf
web_server_home: /srv/www
# UWSGI
uwsgi_venv: "{{ web_server_home }}/virtualenvs/uwsgi"
uwsgi_config: "{{ web_server_home }}/config/uwsgi"
rookeries_uwsgi_ini: rookeries-uwsgi.ini
# Web folders
user: "{{ ansible_env.SUDO_USER }}"
web_app_home: /srv/www