Migrate variables into a separate module.
Turn included playbooks into pure task modules.
This commit is contained in:
parent
dcabd1a549
commit
8892de863c
|
@ -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
|
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
---
|
---
|
||||||
- sudo: yes
|
|
||||||
vars:
|
|
||||||
rookeries_nginx_conf: rookeries-uwsgi_nginx.conf
|
|
||||||
web_server_group: www-data
|
|
||||||
tasks:
|
|
||||||
|
|
||||||
- name: install nginx webserver
|
- name: install nginx webserver
|
||||||
apt: pkg=nginx-full state=present
|
apt: pkg=nginx-full state=present
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: configure nginx
|
- name: configure nginx
|
||||||
copy: src=../config/nginx/{{ rookeries_nginx_conf }} dest=/etc/nginx/sites-available
|
copy: src=../config/nginx/{{ rookeries_nginx_conf }} dest=/etc/nginx/sites-available
|
||||||
|
@ -15,12 +10,15 @@
|
||||||
file: state=link
|
file: state=link
|
||||||
src=/etc/nginx/sites-available/{{ rookeries_nginx_conf }}
|
src=/etc/nginx/sites-available/{{ rookeries_nginx_conf }}
|
||||||
path=/etc/nginx/sites-enabled/{{ rookeries_nginx_conf }}
|
path=/etc/nginx/sites-enabled/{{ rookeries_nginx_conf }}
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: disable the default page configuration
|
- name: disable the default page configuration
|
||||||
file: state=absent path=/etc/nginx/sites-enabled/default
|
file: state=absent path=/etc/nginx/sites-enabled/default
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: restart nginx
|
- name: restart nginx
|
||||||
service: name=nginx state=restarted
|
service: name=nginx state=restarted
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: set permissions on nginx config + log directories
|
- name: set permissions on nginx config + log directories
|
||||||
file: path={{ item }} state=directory
|
file: path={{ item }} state=directory
|
||||||
|
@ -30,6 +28,7 @@
|
||||||
- /etc/nginx
|
- /etc/nginx
|
||||||
- /etc/nginx/sites-available
|
- /etc/nginx/sites-available
|
||||||
- /etc/nginx/sites-enabled
|
- /etc/nginx/sites-enabled
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: set permissions on nginx logs
|
- name: set permissions on nginx logs
|
||||||
file: path=/var/log/nginx/{{ item }} state=file
|
file: path=/var/log/nginx/{{ item }} state=file
|
||||||
|
@ -37,3 +36,4 @@
|
||||||
with_items:
|
with_items:
|
||||||
- access.log
|
- access.log
|
||||||
- error.log
|
- error.log
|
||||||
|
sudo: yes
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
---
|
---
|
||||||
- sudo: yes
|
|
||||||
vars:
|
|
||||||
web_server_group: www-data
|
|
||||||
supervisor_configs:
|
|
||||||
- mailsink_supervisor.conf
|
|
||||||
- rookeries_supervisor.conf
|
|
||||||
tasks:
|
|
||||||
|
|
||||||
- name: install supervisord
|
- name: install supervisord
|
||||||
apt: name=supervisor state=present
|
apt: name=supervisor state=present
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: set permissions on supervisor config and log directories
|
- name: set permissions on supervisor config and log directories
|
||||||
file: path={{ item }} group={{ web_server_group }} state=directory mode=0755
|
file: path={{ item }} group={{ web_server_group }} state=directory mode=0755
|
||||||
|
@ -16,14 +9,17 @@
|
||||||
- /etc/supervisor
|
- /etc/supervisor
|
||||||
- /etc/supervisor/conf.d
|
- /etc/supervisor/conf.d
|
||||||
- /var/log/supervisor
|
- /var/log/supervisor
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: modify supervisor configuration
|
- name: modify supervisor configuration
|
||||||
ini_file: dest=/etc/supervisor/supervisord.conf section=unix_http_server
|
ini_file: dest=/etc/supervisor/supervisord.conf section=unix_http_server
|
||||||
option={{ item.key }} value={{ item.value }}
|
option={{ item.key }} value={{ item.value }}
|
||||||
with_dict:
|
with_dict:
|
||||||
chmod: "0770"
|
chmod: "0770"
|
||||||
chown: root:www-data
|
chown: root:{{ web_server_group }}
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: upload rookeries supervisor configuration to web server home
|
- name: upload rookeries supervisor configuration to web server home
|
||||||
copy: src=../config/supervisor/{{ item }} dest=/etc/supervisor/conf.d
|
copy: src=../config/supervisor/{{ item }} dest=/etc/supervisor/conf.d
|
||||||
with_items: supervisor_configs
|
with_items: supervisor_configs
|
||||||
|
sudo: yes
|
||||||
|
|
|
@ -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
|
- name: install uwsgi server
|
||||||
pip: name=uwsgi virtualenv={{ uwsgi_venv }} version=2.0
|
pip: name=uwsgi virtualenv={{ uwsgi_venv }} version=2.0
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: upload rookeries configuration
|
- name: upload rookeries configuration
|
||||||
copy: src=../config/uwsgi/{{ rookeries_uwsgi_ini }} dest={{ uwsgi_config }}
|
copy: src=../config/uwsgi/{{ rookeries_uwsgi_ini }} dest={{ uwsgi_config }}
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: restart uwsgi server
|
- name: restart uwsgi server
|
||||||
supervisorctl: name=uwsgi state=restarted config=/etc/supervisor/supervisor.conf
|
supervisorctl: name=uwsgi state=restarted config=/etc/supervisor/supervisor.conf
|
||||||
|
sudo: yes
|
||||||
|
|
|
@ -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
|
- 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
|
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
|
- name: setup webapp deployment configuration + log folders with the correct permissions
|
||||||
file: path={{ web_app_home }}/{{ item }} state=directory
|
file: path={{ web_app_home }}/{{ item }} state=directory
|
||||||
|
@ -17,6 +11,7 @@
|
||||||
- config/uwsgi
|
- config/uwsgi
|
||||||
- logs
|
- logs
|
||||||
- virtualenvs
|
- 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: state=link
|
file: state=link
|
||||||
|
@ -28,6 +23,8 @@
|
||||||
/etc/supervisor: config/supervisor
|
/etc/supervisor: config/supervisor
|
||||||
/var/log/nginx: logs/nginx
|
/var/log/nginx: logs/nginx
|
||||||
/var/log/supervisor: logs/supervisor
|
/var/log/supervisor: logs/supervisor
|
||||||
|
sudo: yes
|
||||||
|
|
||||||
- name: add user to www-data
|
- name: add user to www-data
|
||||||
user: name={{ user }} append=yes groups={{ web_server_group }}
|
user: name={{ user }} append=yes groups={{ web_server_group }}
|
||||||
|
sudo: yes
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue