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: web_data_folders.yaml
|
||||
- include: uwsgi.yaml
|
||||
|
||||
# TODO Add in globally defined values for webapp and virtualenv folders
|
||||
|
|
|
@ -1,28 +1,26 @@
|
|||
---
|
||||
- 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
|
||||
sudo: yes
|
||||
|
||||
- name: configure nginx
|
||||
- name: configure nginx
|
||||
copy: src=../config/nginx/{{ rookeries_nginx_conf }} dest=/etc/nginx/sites-available
|
||||
|
||||
- name: enable the rookeries nginx configuration
|
||||
- name: enable the rookeries nginx configuration
|
||||
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
|
||||
- name: disable the default page configuration
|
||||
file: state=absent path=/etc/nginx/sites-enabled/default
|
||||
sudo: yes
|
||||
|
||||
- name: restart nginx
|
||||
- name: restart nginx
|
||||
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
|
||||
group={{ web_server_group }} mode=0755
|
||||
with_items:
|
||||
|
@ -30,10 +28,12 @@
|
|||
- /etc/nginx
|
||||
- /etc/nginx/sites-available
|
||||
- /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
|
||||
owner={{ web_server_group }} group={{ web_server_group }} mode=0644
|
||||
with_items:
|
||||
- access.log
|
||||
- error.log
|
||||
sudo: yes
|
||||
|
|
|
@ -1,29 +1,25 @@
|
|||
---
|
||||
- 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
|
||||
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
|
||||
with_items:
|
||||
- /etc/supervisor
|
||||
- /etc/supervisor/conf.d
|
||||
- /var/log/supervisor
|
||||
sudo: yes
|
||||
|
||||
- name: modify supervisor configuration
|
||||
- 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
|
||||
- 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
|
||||
|
|
|
@ -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
|
||||
sudo: yes
|
||||
|
||||
- name: upload rookeries configuration
|
||||
- name: upload rookeries configuration
|
||||
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
|
||||
sudo: yes
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
---
|
||||
- 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
|
||||
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
|
||||
owner={{ web_server_group }} group={{ web_server_group }} mode=0774
|
||||
with_items:
|
||||
|
@ -17,8 +11,9 @@
|
|||
- 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: state=link
|
||||
path={{ web_app_home }}/{{ item.value }}
|
||||
src={{ item.key }}
|
||||
|
@ -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
|
||||
- name: add user to www-data
|
||||
user: name={{ user }} append=yes groups={{ web_server_group }}
|
||||
sudo: yes
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue