Add nodejs fixed setup that works with latest nodejs. Fix up deployment tasks to run only when a deployment package is available.

This commit is contained in:
Dorian 2015-05-15 23:53:54 -04:00
parent 54883a744d
commit b1b6dc5915
2 changed files with 31 additions and 18 deletions

View File

@ -1,10 +1,24 @@
--- ---
- name: install nodejs + npm dependencies - name: install systems to help setup nodejs
apt: pkg={{ item }} state=present apt: pkg={{ item }} state=present
with_items: with_items:
- nodejs - python-apt
- npm
- git - git
- apt-transport-https
- name: add the nodesource repository
apt_key: url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key state=present
- name: add the nodesource binary repository
apt_repository: repo="deb https://deb.nodesource.com/node_0.12 {{ ansible_lsb.codename }} main"
state=present
- name: add the nodesource source repository
apt_repository: repo="deb-src https://deb.nodesource.com/node_0.12 {{ ansible_lsb.codename }} main"
state=present update_cache=yes
- name: install nodejs + npm
apt: pkg=nodejs state=present
- name: check if nodejs binary exists and needs linking to node binary - name: check if nodejs binary exists and needs linking to node binary
stat: path=/usr/bin/nodejs stat: path=/usr/bin/nodejs
@ -12,10 +26,10 @@
- name: link nodejs binary correctly - name: link nodejs binary correctly
file: src=/usr/bin/nodejs dest=/usr/bin/node state=link file: src=/usr/bin/nodejs dest=/usr/bin/node state=link
when: nodejs_bin.exists when: nodejs_bin.stat.exists
- name: install coffeescript + less dependencies - name: install coffeescript + less dependencies
npm: name={{ item }} global=yes state=present npm: name={{ item }} global=yes state=present registry=http://registry.npmjs.org/
with_items: with_items:
- coffee-script - coffee-script
- less - less

View File

@ -1,31 +1,30 @@
--- ---
- name: verify a deployment package ready for deployment, otherwise skip deployment steps
local_action: stat path={{ rookeries_package_path }}
sudo: no
register: deploy_package
- name: upload + extract rookeries package to web server home - name: upload + extract rookeries package to web server home
unarchive: src={{ rookeries_package_path }} dest={{ web_root_path }} unarchive: src={{ rookeries_package_path }} dest={{ web_root_path }}
sudo: yes sudo: yes
register: ready_to_deploy when: deploy_package.stat.exists
ignore_errors: True
- command: echo Hello {{ app_root_path }}
- name: install rookeries dependencies - name: install rookeries dependencies
pip: requirements=requirements.txt virtualenv={{ rookeries_venv }} chdir={{ app_root_path }} pip: requirements=requirements.txt virtualenv={{ rookeries_venv }} chdir={{ app_root_path }}
when: ready_to_deploy|success when: deploy_package.stat.exists
- name: install extra MySQL python connector dependency - name: install extra MySQL python connector dependency
pip: name=mysql-connector-python virtualenv={{ rookeries_venv }} version=1.1.6 pip: name=mysql-connector-python virtualenv={{ rookeries_venv }} version=1.1.6
extra_args='--allow-external mysql-connector-python --allow-unverified mysql-connector-python' extra_args="--allow-external mysql-connector-python --allow-unverified mysql-connector-python"
when: ready_to_deploy|success when: deploy_package.stat.exists
- name: fix permissions on extracted web app - name: fix permissions on extracted web app
file: path={{ app_root_path }} owner={{ web_server_group }} group={{ web_server_group }} file: path={{ app_root_path }} owner={{ web_server_group }} group={{ web_server_group }}
state=directory recurse=yes state=directory recurse=yes
when: ready_to_deploy|success when: deploy_package.stat.exists
# TODO Step 4 - Setup environment variables on target system related to config.
# TODO Replace with npm installation in the future.
- name: install bower dependencies in app - name: install bower dependencies in app
command: bower install --allow-root --quiet chdir={{ web_root_path }}/rookeries_webapp command: bower install --allow-root --quiet chdir={{ web_root_path }}/rookeries_webapp
notify: restart uwsgi app notify: restart uwsgi app
when: ready_to_deploy|success when: deploy_package.stat.exists
# TODO Replace with bower command in future version of Ansible (1.9.0)
# bower: path={{ app_root_path }} state=present