-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybookubuntu.yml
More file actions
82 lines (68 loc) · 2.51 KB
/
playbookubuntu.yml
File metadata and controls
82 lines (68 loc) · 2.51 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
- hosts: localhost
become: yes
vars:
node_apps_location: /usr/local/opt/node
tasks:
- name: Ensure ufw is running
service: name=ufw state=started
#- name: Allow everything and enable UFW
# community.general.ufw:
# state: enabled
# policy: allow
#
#- name: Set logging
# community.general.ufw:
# logging: 'on'
#
# Sometimes it is desirable to let the sender know when traffic is
# being denied, rather than simply ignoring it. In these cases, use
# reject instead of deny. In addition, log rejected connections:
#- community.general.ufw:
# rule: reject
# port: auth
# log: yes
# ufw supports connection rate limiting, which is useful for protecting
# against brute-force login attacks. ufw will deny connections if an IP
# address has attempted to initiate 6 or more connections in the last
# 30 seconds. See http://www.debian-administration.org/articles/187
# for details. Typical usage is:
#- community.general.ufw:
# rule: limit
# port: ssh
# proto: tcp #
# Allow OpenSSH. (Note that as ufw manages its own state, simply removing
# a rule=allow task can leave those ports exposed. Either use delete=yes
# or a separate state=reset task)
#- community.general.ufw:
# rule: allow
# name: OpenSSH
#
#- name: Allow all access to tcp port 80
# community.general.ufw:
# rule: allow
# port: '80'
# proto: tcp
- name : Install npm package
apt: name=npm state=present update_cache=true
- name : Install nodejs package
apt: name=nodejs state=present update_cache=true
- name: Install Forever (to run our Node.js app).
npm: name=forever global=yes state=present
- name: create directory for nodejs scripts
file:
path: "{{ node_apps_location }}"
state: directory
- 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: forever list
register: forever_list
changed_when: false
- name: Start example Node.js app.
command: "forever start {{ node_apps_location }}/app/app.js"
when: "forever_list.stdout.find(node_apps_location + '/app/app.js') == -1"