forked from geerlingguy/ansible-for-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
44 lines (33 loc) · 1.22 KB
/
playbook.yml
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
---
- hosts: all
vars:
node_apps_location: /usr/local/opt/node
pre_tasks:
- name: Import Remi GPG key.
rpm_key:
key: "https://rpms.remirepo.net/RPM-GPG-KEY-remi2018"
state: present
- name: Install Remi repo.
dnf:
name: "https://rpms.remirepo.net/enterprise/remi-release-8.rpm"
state: present
- name: Install EPEL repo.
dnf: name=epel-release state=present
- name: Ensure firewalld is stopped (since this is a test server).
service: name=firewalld state=stopped
roles:
- nodejs
tasks:
- name: Ensure Node.js app folder exists.
file: "path={{ node_apps_location }} state=directory"
- name: Copy example Node.js app to server.
copy: "src=app dest={{ node_apps_location }}"
- name: Install app dependencies defined in package.json.
npm: "path={{ node_apps_location }}/app"
- name: Check list of running Node.js apps.
command: /usr/local/bin/forever list
register: forever_list
changed_when: false
- name: Start example Node.js app.
command: "/usr/local/bin/forever start {{ node_apps_location }}/app/app.js"
when: "forever_list.stdout.find(node_apps_location + '/app/app.js') == -1"