forked from robipozzi/windfire-restaurants-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.yaml
More file actions
45 lines (45 loc) · 1.46 KB
/
deploy.yaml
File metadata and controls
45 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--- # Ansible Playbook to automate application deployment to Raspberry Pis in a consistent and repeatable way
- hosts: raspberry
remote_user: "{{ user }}"
become: yes
vars:
src_dir: "{{ playbook_dir }}"
nodejs_src_dir: "{{ lookup('env', 'PWD') }}/app"
service_name: windfire-restaurants-node
mode: u=rwx
vars_files:
- "{{ src_dir }}/conf/raspberry-config.yml"
tasks:
- name: Install pm2 process manager for Node.js
npm:
name: pm2
global: yes
production: yes
state: present
- name: Stop Node.js application service {{ service_name }}
shell: pm2 stop {{ service_name }}
ignore_errors: yes
- name: Delete Node.js application service {{ service_name }}
shell: pm2 delete {{ service_name }}
ignore_errors: yes
- name: Clean Node.js application folder {{ remote_nodejs_dest_dir }}
file:
path: "{{ remote_nodejs_dest_dir }}"
state: absent
- name: Transfer Node.js Files
copy:
src: "{{ nodejs_src_dir }}"
dest: "{{ remote_nodejs_dest_dir }}"
owner: "{{ user }}"
group: "{{ group }}"
mode: "{{ mode }}"
- name: install node dependencies
shell: npm install
become: true
args:
chdir: "{{ remote_nodejs_app_dir }}"
- name: Start Node.js application service
command: pm2 start app.js --name {{ service_name }}
become: true
args:
chdir: "{{ remote_nodejs_app_dir }}"