From b1b6dc591512a78907ac17b097351f1d220cf1b3 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Fri, 15 May 2015 23:53:54 -0400 Subject: [PATCH] Add nodejs fixed setup that works with latest nodejs. Fix up deployment tasks to run only when a deployment package is available. --- tasks/nodejs.yaml | 24 +++++++++++++++++++----- tasks/rookeries_deployment.yaml | 25 ++++++++++++------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/tasks/nodejs.yaml b/tasks/nodejs.yaml index c40ff79..4b471bc 100644 --- a/tasks/nodejs.yaml +++ b/tasks/nodejs.yaml @@ -1,10 +1,24 @@ --- -- name: install nodejs + npm dependencies +- name: install systems to help setup nodejs apt: pkg={{ item }} state=present with_items: - - nodejs - - npm + - python-apt - 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 stat: path=/usr/bin/nodejs @@ -12,10 +26,10 @@ - name: link nodejs binary correctly 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 - npm: name={{ item }} global=yes state=present + npm: name={{ item }} global=yes state=present registry=http://registry.npmjs.org/ with_items: - coffee-script - less diff --git a/tasks/rookeries_deployment.yaml b/tasks/rookeries_deployment.yaml index b727557..feaa976 100644 --- a/tasks/rookeries_deployment.yaml +++ b/tasks/rookeries_deployment.yaml @@ -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 unarchive: src={{ rookeries_package_path }} dest={{ web_root_path }} sudo: yes - register: ready_to_deploy - ignore_errors: True - -- command: echo Hello {{ app_root_path }} + when: deploy_package.stat.exists - name: install rookeries dependencies 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 pip: name=mysql-connector-python virtualenv={{ rookeries_venv }} version=1.1.6 - extra_args='--allow-external mysql-connector-python --allow-unverified mysql-connector-python' - when: ready_to_deploy|success + extra_args="--allow-external mysql-connector-python --allow-unverified mysql-connector-python" + when: deploy_package.stat.exists - name: fix permissions on extracted web app file: path={{ app_root_path }} owner={{ web_server_group }} group={{ web_server_group }} state=directory recurse=yes - when: ready_to_deploy|success - -# TODO Step 4 - Setup environment variables on target system related to config. + when: deploy_package.stat.exists +# TODO Replace with npm installation in the future. - name: install bower dependencies in app command: bower install --allow-root --quiet chdir={{ web_root_path }}/rookeries_webapp notify: restart uwsgi app - when: ready_to_deploy|success - # TODO Replace with bower command in future version of Ansible (1.9.0) - # bower: path={{ app_root_path }} state=present + when: deploy_package.stat.exists