-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-node.yaml
49 lines (45 loc) · 1.26 KB
/
deploy-node.yaml
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
46
47
48
49
---
- name: Install node and npm
hosts: 159.89.1.54
tasks:
- name: Update apt repo and cache
ansible.builtin.apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
- name: Install nodejs and npm
ansible.builtin.apt:
pkg:
- nodejs
- npm
- name: Create new linux user for node app
hosts: 159.89.1.54
vars_files:
- project-vars
tasks:
- name: Create linux user
ansible.builtin.user:
name: "{{linux_name}}"
comment: Node User
group: admin
- name: Deploy nodejs app
hosts: 159.89.1.54
become: True
become_user: "{{linux_name}}"
vars_files:
- project-vars
tasks:
- name: Unpack the nodejs file
ansible.builtin.unarchive:
src: "{{location}}/nodejs-app-{{version}}.tgz"
dest: "{{user_home_dir}}"
- name: Install dependencies
community.general.npm:
path: "{{user_home_dir}}/package"
- name: Start the application
ansible.builtin.command:
chdir: "{{user_home_dir}}/package/app"
cmd: node server
async: 1000
poll: 0
- name: Ensure app is running
ansible.builtin.shell: ps aux | grep node
register: app_status
- ansible.builtin.debug: msg={{app_status.stdout_lines}}