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: supervisor.yaml
- include: web_data_folders.yaml - include: web_data_folders.yaml
- include: uwsgi.yaml - include: uwsgi.yaml
# TODO Add in globally defined values for webapp and virtualenv folders

View File

@ -1,39 +1,39 @@
--- ---
- sudo: yes - name: install nginx webserver
vars: apt: pkg=nginx-full state=present
rookeries_nginx_conf: rookeries-uwsgi_nginx.conf sudo: yes
web_server_group: www-data
tasks:
- name: install nginx webserver - name: configure nginx
apt: pkg=nginx-full state=present copy: src=../config/nginx/{{ rookeries_nginx_conf }} dest=/etc/nginx/sites-available
- name: configure nginx - name: enable the rookeries nginx configuration
copy: src=../config/nginx/{{ rookeries_nginx_conf }} dest=/etc/nginx/sites-available file: state=link
src=/etc/nginx/sites-available/{{ rookeries_nginx_conf }}
path=/etc/nginx/sites-enabled/{{ rookeries_nginx_conf }}
sudo: yes
- name: enable the rookeries nginx configuration - name: disable the default page configuration
file: state=link file: state=absent path=/etc/nginx/sites-enabled/default
src=/etc/nginx/sites-available/{{ rookeries_nginx_conf }} sudo: yes
path=/etc/nginx/sites-enabled/{{ rookeries_nginx_conf }}
- name: disable the default page configuration - name: restart nginx
file: state=absent path=/etc/nginx/sites-enabled/default service: name=nginx state=restarted
sudo: yes
- name: restart nginx - name: set permissions on nginx config + log directories
service: name=nginx state=restarted file: path={{ item }} state=directory
group={{ web_server_group }} mode=0755
with_items:
- /var/log/nginx
- /etc/nginx
- /etc/nginx/sites-available
- /etc/nginx/sites-enabled
sudo: yes
- name: set permissions on nginx config + log directories - name: set permissions on nginx logs
file: path={{ item }} state=directory file: path=/var/log/nginx/{{ item }} state=file
group={{ web_server_group }} mode=0755 owner={{ web_server_group }} group={{ web_server_group }} mode=0644
with_items: with_items:
- /var/log/nginx - access.log
- /etc/nginx - error.log
- /etc/nginx/sites-available sudo: yes
- /etc/nginx/sites-enabled
- name: set permissions on nginx logs
file: path=/var/log/nginx/{{ item }} state=file
owner={{ web_server_group }} group={{ web_server_group }} mode=0644
with_items:
- access.log
- error.log

View File

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

View File

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

View File

@ -1,33 +1,30 @@
--- ---
- sudo: yes - name: setup webapp deployment folder with the correct permissions
vars: file: path={{ web_app_home }} state=directory owner={{ web_server_group }} group=www-data mode=0774
user: "{{ ansible_env.SUDO_USER }}" sudo: yes
web_app_home: /srv/www
web_server_group: www-data
tasks: - name: setup webapp deployment configuration + log folders with the correct permissions
- name: setup webapp deployment folder with the correct permissions file: path={{ web_app_home }}/{{ item }} state=directory
file: path={{ web_app_home }} state=directory owner={{ web_server_group }} group=www-data mode=0774 owner={{ web_server_group }} group={{ web_server_group }} mode=0774
with_items:
- config
- config/uwsgi
- logs
- virtualenvs
sudo: yes
- name: setup webapp deployment configuration + log folders with the correct permissions - name: setup webapp deployment configuration + log folders with the correct permissions
file: path={{ web_app_home }}/{{ item }} state=directory file: state=link
owner={{ web_server_group }} group={{ web_server_group }} mode=0774 path={{ web_app_home }}/{{ item.value }}
with_items: src={{ item.key }}
- config owner={{ web_server_group }} group={{ web_server_group }} mode=0774
- config/uwsgi with_dict:
- logs /etc/nginx: config/nginx
- virtualenvs /etc/supervisor: config/supervisor
/var/log/nginx: logs/nginx
/var/log/supervisor: logs/supervisor
sudo: yes
- name: setup webapp deployment configuration + log folders with the correct permissions - name: add user to www-data
file: state=link user: name={{ user }} append=yes groups={{ web_server_group }}
path={{ web_app_home }}/{{ item.value }} sudo: yes
src={{ item.key }}
owner={{ web_server_group }} group={{ web_server_group }} mode=0774
with_dict:
/etc/nginx: config/nginx
/etc/supervisor: config/supervisor
/var/log/nginx: logs/nginx
/var/log/supervisor: logs/supervisor
- name: add user to www-data
user: name={{ user }} append=yes groups={{ web_server_group }}

View File

@ -1,2 +1,24 @@
--- ---
# vars file for ansible-nginx-uwsgi-supervisor # 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