diff --git a/README.md b/README.md index 365e605..b365704 100644 --- a/README.md +++ b/README.md @@ -125,9 +125,6 @@ Internal Variables The following variables are part of the internals of the role. However if you really want to, you can tweak them to work with your setup: -- web_user: - - The non-root user who is allowed to control web + app servers on the target machine. - - Default: current user - virtualenv_root_path: - The common root directory of Python virtual environments associated with running the UWSGI app + server. diff --git a/handlers/main.yml b/handlers/main.yml index ae30b4b..f09ea85 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -3,7 +3,3 @@ - name: restart uwsgi app supervisorctl: name={{ uwsgi_app_service_name }} state=restarted config=/etc/supervisor/supervisord.conf sudo: yes - -- name: restart nginx - service: name=nginx state=restarted - sudo: yes diff --git a/tasks/main.yml b/tasks/main.yml index 119d37b..65209b2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,4 @@ --- # tasks file for ansible-nginx-uwsgi-supervisor -- include: nginx.yaml - include: python.yaml - include: uwsgi.yaml diff --git a/tasks/nginx.yaml b/tasks/nginx.yaml deleted file mode 100644 index 9e3f0fa..0000000 --- a/tasks/nginx.yaml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- name: install nginx webserver - apt: pkg=nginx-full state=present - sudo: yes - -- name: configure nginx - template: src=nginx/app_uwsgi_nginx.conf dest=/etc/nginx/sites-available/{{ nginx_app_config }} - sudo: yes - -- name: link to enable nginx configuration - file: state=link - src=/etc/nginx/sites-available/{{ nginx_app_config }} - path=/etc/nginx/sites-enabled/{{ nginx_app_config }} - sudo: yes - -- name: disable default configuration - file: state=absent path=/etc/nginx/sites-enabled/default - sudo: yes - notify: restart nginx - -- name: set nginx directories permissions - 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 nginx logs permissions - 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 diff --git a/tasks/uwsgi.yaml b/tasks/uwsgi.yaml index 24aaad4..e1eb623 100644 --- a/tasks/uwsgi.yaml +++ b/tasks/uwsgi.yaml @@ -4,5 +4,17 @@ sudo: yes - name: configure app on uwsgi server - template: src=uwsgi/app_uwsgi.ini dest={{ uwsgi_config_path }}/{{ uwsgi_app_ini }} + template: src=app_uwsgi.ini dest={{ uwsgi_config_path }}/{{ uwsgi_app_ini }} sudo: yes + notify: restart uwsgi app + +- name: configure nginx app with uwsgi specific block. + blockinfile: + dest: /etc/nginx/sites-available/{{ nginx_app_config }} + insertafter: "# Include your setup to connect to the webapp setup here." + marker: "# -- {mark} UWSGI App config for {{ app_name }} --" + block: | + include uwsgi_params; + uwsgi_pass 127.0.0.1:{{ app_uwsgi_port }}; + sudo: yes + notify: restart nginx diff --git a/templates/uwsgi/app_uwsgi.ini b/templates/app_uwsgi.ini similarity index 100% rename from templates/uwsgi/app_uwsgi.ini rename to templates/app_uwsgi.ini diff --git a/templates/nginx/app_uwsgi_nginx.conf b/templates/nginx/app_uwsgi_nginx.conf deleted file mode 100644 index 125ba5b..0000000 --- a/templates/nginx/app_uwsgi_nginx.conf +++ /dev/null @@ -1,18 +0,0 @@ -server { - - server_name {{ app_nginx_hostname }}; - access_log {{ web_root_path }}/logs/nginx/{{ app_name }}-access.log; - error_log {{ web_root_path }}/logs/nginx/{{ app_name }}-error.log info; - - location /static/ { - alias {{ app_nginx_static_path }}; - } - - location / { - try_files $uri @yourapplication; - } - location @yourapplication { - include uwsgi_params; - uwsgi_pass 127.0.0.1:{{ app_uwsgi_port }}; - } -} \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml index 403faca..3a0dad9 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,13 +1,9 @@ --- # vars file for ansible-nginx-uwsgi-supervisor -# User -web_user: "{{ ansible_env.SUDO_USER }}" - # NGINX nginx_app_config: "{{ app_name }}_uwsgi_nginx.conf" - # UWSGI uwsgi_venv: "{{ virtualenv_root_path }}/uwsgi" uwsgi_config_path: "{{ web_root_path }}/config/uwsgi"