This repository was archived by the owner on May 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpm2.yml
More file actions
41 lines (33 loc) · 1.23 KB
/
pm2.yml
File metadata and controls
41 lines (33 loc) · 1.23 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
# Optional Variables
# pm2_config_apps - defaults to False
# pm2_json_src_path - the path to PM2 json application config file on the Ansible Managment Node
# pm2_json_dest_path - the path to which the PM2 json application config file should be copied to on target host
# username - username for the target host (e.g., ubuntu, vagrant, etc)
- name: pm2_config_apps
set_fact:
pm2_config_apps: False
when: pm2_config_apps is undefined
- name: Install PM2
become_user: root
npm: name=pm2 global=yes
- debug:
msg: "{{pm2_json_dest_path}}"
- name: Copy PM2 JSON config
template:
src: "{{pm2_json_src_path}}"
dest: "{{pm2_json_dest_path}}"
when: pm2_config_apps == True
- name: Remove all apps from PM2 manager
command: pm2 delete all
when: pm2_config_apps == True
ignore_errors: yes
- name: Create PM2 startup script 2
become_user: root
command: env PATH=$PATH:/usr/bin pm2 startup {{pm2_username}} -u {{pm2_username}} --hp /home/{{pm2_username}}
when: pm2_config_apps == True
- name: Start the PM2 apps
command: pm2 start {{pm2_json_dest_path}}
when: pm2_config_apps == True
- name: Save PM2 configuration
command: pm2 save
when: pm2_config_apps == True