mirror of
https://github.com/koodiklinikka/koodiklinikka.fi-api.git
synced 2026-01-26 03:34:03 +00:00
57 lines
1.5 KiB
YAML
57 lines
1.5 KiB
YAML
---
|
|
- name: Deploy API
|
|
hosts: all:!localhost
|
|
remote_user: "{{ service_user }}"
|
|
gather_facts: no
|
|
vars_files:
|
|
- vars.yml
|
|
tasks:
|
|
- name: Deploy from git
|
|
action: >
|
|
git
|
|
repo="{{ repository_url }}"
|
|
dest="{{ projects_path }}"
|
|
accept_hostkey=True
|
|
notify: restart service
|
|
|
|
- name: Setup bot config
|
|
copy: >
|
|
src=/opt/web/config/api.json
|
|
dest="{{ projects_path }}/config.json"
|
|
owner=web
|
|
group=web
|
|
mode=0644
|
|
notify: restart service
|
|
|
|
- name: Install NVM
|
|
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
|
|
notify: restart service
|
|
|
|
- name: Install NPM dependencies and build assets
|
|
command: >
|
|
bash -c "source {{ nvm_script }} && nvm use {{ project_name }} && cd {{ projects_path }} && npm install"
|
|
notify: restart service
|
|
|
|
- name: Setup Upstart config
|
|
template: >
|
|
src=templates/upstart.j2
|
|
dest="/etc/init/{{ project_name }}.conf"
|
|
mode=664
|
|
notify: restart service
|
|
|
|
handlers:
|
|
- name: restart service
|
|
service: >
|
|
name={{ project_name }}
|
|
state=restarted
|