Add a default setup for running and serving a NodeJS application.

This commit is contained in:
Dorian 2016-05-17 18:17:49 -04:00
parent 6869095e60
commit 5b9cad7359
5 changed files with 37 additions and 14 deletions

View File

@ -1,4 +1,20 @@
--- ---
# defaults file for nodejs-nginx-supervisor # defaults file for nodejs-nginx-supervisor
app_name: "nodejs_app" web_root: /srv/www
nodejs_app_name: "nodejs_app"
nodejs_app_port: 3000
nodejs_app_script: "src/index.js"
nodejs_app_root_path: "{{ web_root }}/{{ nodejs_app_name }}"
nodejs_app_nginx_hostname: localhost
nodejs_app_supervisor_command: "PORT={{ nodejs_app_port }} node {{ nodejs_app_root }}/{{ nodejs_app_script }}"
nodejs_version_family: "5.x"
# Other valid value is 4.x
nodejs_app_global_install:
- browserify
- babel-cli
- less

View File

@ -1,2 +0,0 @@
---
# handlers file for nodejs-nginx-supervisor

View File

@ -22,17 +22,14 @@ galaxy_info:
dependencies: dependencies:
# - role: "git+https://bitbucket.org/dorianpula/ansible-nginx-uwsgi-supervisor,,nginx-uwsgi-supervisor" # - role: "git+https://bitbucket.org/dorianpula/ansible-nginx-uwsgi-supervisor,,nginx-uwsgi-supervisor"
- role: "nginx-supervisor" - role: "nginx-supervisor"
nsbase_app_name: "{{ app_name }}" nsbase_app_name: "{{ nodejs_app_name }}"
nsbase_app_root_path: "{{ app_root_path }}" nsbase_app_root_path: "{{ nodejs_app_root_path }}"
nsbase_app_nginx_hostname: "{{ app_nginx_hostname }}" nsbase_app_nginx_hostname: "{{ nodejs_app_nginx_hostname }}"
nsbase_app_service_name: "{{ nodejs_app_service_name }}" nsbase_app_service_name: "{{ nodejs_app_service_name }}"
nsbase_app_service_command: "{{ nodejs_supervisor_app_command }}" nsbase_app_service_command: "{{ nodejs_app_supervisor_command }}"
nsbase_app_service_stop_signal: QUIT nsbase_app_service_stop_signal: QUIT
nsbase_nginx_app_config: "{{ nodejs_nginx_app_config }}" nsbase_nginx_app_config: "{{ nodejs_app_nginx_config }}"
# - role: "git+https://bitbucket.org/dorianpula/ansible-nodejs,,nodejs" # - role: "git+https://bitbucket.org/dorianpula/ansible-nodejs,,nodejs"
- role: "nodejs" - role: "nodejs"
node_version_family: "5.x" node_version_family: "{{ nodejs_version_family }}"
globally_installed_tools: globally_installed_tools: nodejs_app_global_install
- browserify
- babel-cli
- less

View File

@ -1,2 +1,12 @@
--- ---
# tasks file for nodejs-nginx-supervisor - name: configure nginx app with nodejs specific block.
blockinfile:
dest: /etc/nginx/sites-available/{{ nodejs_app_nginx_config }}
insertafter: "# Include your setup to connect to the webapp setup here."
marker: "# -- {mark} NodeJS App config for {{ nodejs_app_name }} --"
block: |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass 127.0.0.1:{{ nodejs_app_port }};
sudo: yes
notify: restart nginx

View File

@ -1,2 +1,4 @@
--- ---
# vars file for nodejs-nginx-supervisor # vars file for nodejs-nginx-supervisor
nodejs_app_nginx_config: "{{ app_name }}_nodejs_nginx.conf"
nodejs_app_service_name: "{{ app_name }}_nodejs"