mirror of
https://github.com/koodiklinikka/koodiklinikka.fi.git
synced 2026-02-07 15:50:08 +00:00
51 lines
1.5 KiB
YAML
51 lines
1.5 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
|
|
remote_user: "{{ service_user }}"
|
|
template: >
|
|
src=templates/nginx.j2
|
|
dest="/etc/nginx/sites-available/koodiklinikka/{{ public_hostname }}"
|
|
mode=664
|
|
notify: restart nginx
|
|
|
|
handlers:
|
|
- name: restart nginx
|
|
sudo: true
|
|
remote_user: "{{ service_user }}"
|
|
service: >
|
|
name=nginx
|
|
state=restarted
|