From d99bc0edce0b0ee9c20b9857fa3aee9c994a8a7f Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Wed, 26 Nov 2014 22:04:01 -0500 Subject: [PATCH] Add separate ansible playbook for setting up webapp folders. Add logging configuration for rookeries. --- config/nginx/rookeries-uwsgi.conf | 12 ++++++++---- pre_deployment.yaml | 1 + pre_deployment/nginx.yaml | 12 ------------ pre_deployment/python.yaml | 2 +- pre_deployment/web_data_folders.yaml | 22 ++++++++++++++++++++++ 5 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 pre_deployment/web_data_folders.yaml diff --git a/config/nginx/rookeries-uwsgi.conf b/config/nginx/rookeries-uwsgi.conf index 68b6955..84496ee 100644 --- a/config/nginx/rookeries-uwsgi.conf +++ b/config/nginx/rookeries-uwsgi.conf @@ -1,14 +1,18 @@ server { server_name localhost; + access_log /srv/www/logs/nginx/rookeries-access.log; + error_log /srv/www/logs/nginx/rookeries-error.log info; location /static/ { - alias /srv/www/rookeries_webapp/rookeries/static/; + alias /srv/www/rookeries_webapp/rookeries/static/; } - location / { try_files $uri @yourapplication; } + location / { + try_files $uri @yourapplication; + } location @yourapplication { - include uwsgi_params; - uwsgi_pass 127.0.0.1:8001; + include uwsgi_params; + uwsgi_pass 127.0.0.1:8001; } } \ No newline at end of file diff --git a/pre_deployment.yaml b/pre_deployment.yaml index eb284ff..a8bd826 100644 --- a/pre_deployment.yaml +++ b/pre_deployment.yaml @@ -2,5 +2,6 @@ - include: pre_deployment/base_linux.yaml - include: pre_deployment/python.yaml - include: pre_deployment/mysql_db.yaml +- include: pre_deployment/web_data_folders.yaml - include: pre_deployment/nodejs.yaml - include: pre_deployment/nginx.yaml diff --git a/pre_deployment/nginx.yaml b/pre_deployment/nginx.yaml index 763008e..6551d84 100644 --- a/pre_deployment/nginx.yaml +++ b/pre_deployment/nginx.yaml @@ -4,7 +4,6 @@ vars: rookeries_nginx_conf: rookeries-uwsgi.conf web_server_group: www-data - web_server_home: /srv/www tasks: - name: Setup nginx webserver @@ -24,17 +23,6 @@ - name: Run nginx service service: name=nginx state=restarted - - name: Setup webapp deployment folder with the correct permissions - file: path={{ web_server_home }} state=directory - owner={{ ansible_env.SUDO_USER }} group={{ web_server_group }} mode=0774 - - - name: Setup webapp deployment configuration folder with the correct permissions - file: path={{ web_server_home }}/config state=directory - owner={{ ansible_env.SUDO_USER }} group={{ web_server_group }} mode=0774 - - - name: Add vagrant user to www-data - user: name={{ ansible_env.SUDO_USER }} append=yes groups={{ web_server_group }} - - name: Change permissions on nginx logs file: path=/var/log/nginx state=directory owner={{ web_server_group }} group={{ web_server_group }} mode=0766 diff --git a/pre_deployment/python.yaml b/pre_deployment/python.yaml index 72706a4..0c14f78 100644 --- a/pre_deployment/python.yaml +++ b/pre_deployment/python.yaml @@ -13,6 +13,6 @@ easy_install: name=pip - name: Basic Python dependencies - pip: name={{ item }} use_mirrors=no + pip: name={{ item }} with_items: - virtualenv diff --git a/pre_deployment/web_data_folders.yaml b/pre_deployment/web_data_folders.yaml new file mode 100644 index 0000000..893bdee --- /dev/null +++ b/pre_deployment/web_data_folders.yaml @@ -0,0 +1,22 @@ +--- +- hosts: all + 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 + + - 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: + - config + - logs + - logs/nginx + + - name: add user to www-data + user: name={{ user }} append=yes groups={{ web_server_group }}