Files
koodiklinikka.fi/deploy/deploy.yml
2015-01-13 23:30:33 +02:00

58 lines
1.6 KiB
YAML

---
- name: Deploy koodiklinikka.fi
hosts: all:!localhost
gather_facts: no
vars_files:
- vars.yml
tasks:
- name: Deploy client from git
remote_user: "{{ service_user }}"
action: >
git
repo="{{ repository_url }}"
dest="{{ projects_path }}"
accept_hostkey=True
- name: Install NVM
remote_user: "{{ service_user }}"
action: >
git
repo="https://github.com/creationix/nvm"
dest="{{ nvm_path }}"
- name: Make sure Node.js is installed and properly aliased
command: >
bash -c "source {{ nvm_script }} && nvm install {{ nodejs_version }} && nvm alias {{ project_name }} {{ nodejs_version }}"
register: nvm_result
changed_when: >
"already installed" not in nvm_result.stdout
remote_user: "{{ service_user }}"
- name: Install client NPM dependencies and build assets
command: >
bash -c "source {{ nvm_script }} && nvm use {{ project_name }} && cd {{ projects_path }} && npm install && NODE_ENV=production npm run build"
remote_user: "{{ service_user }}"
- name: Setup nginx vhost
sudo: yes
template: >
src=templates/nginx.j2
dest="/etc/nginx/sites-available/{{ public_hostname }}"
mode=664
notify: restart nginx
- name: Enable nginx vhost
sudo: yes
file: >
state=link
src=/etc/nginx/sites-available/{{ public_hostname }}
dest=/etc/nginx/sites-enabled/{{ public_hostname }}
notify: restart nginx
handlers:
- name: restart nginx
sudo: true
service: >
name=nginx
state=restarted