add deployment stuff

This commit is contained in:
Riku Rouvila
2015-01-13 23:30:33 +02:00
parent 9a47b9e559
commit fb7b776e87
6 changed files with 102 additions and 1 deletions

57
deploy/deploy.yml Normal file
View File

@@ -0,0 +1,57 @@
---
- 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