forked from siamaksade/openshift-jenkins-demo
-
Notifications
You must be signed in to change notification settings - Fork 3
/
app_ec2_deploy.yml
84 lines (73 loc) · 1.69 KB
/
app_ec2_deploy.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
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
83
84
---
- name: Deploy Application to EC2 Instances
hosts: all
gather_facts: true
roles:
- role: geerlingguy.nodejs
vars:
nodejs_version: "10.x"
environment:
NODE_ENV: devsecops
tags:
- app_deploy
- webservers
- devsecops
tasks:
- name: Set NODE_ENV for config
lineinfile:
state: present
line: "export NODE_ENV=devsecops"
insertafter: EOF
path: /etc/profile
tags:
- node-env
- name: debug facts stored from tower host
debug:
var: hostvars['tower-rhel']['new_pkg_version']
verbosity: 2
tags:
- app-deploy
- debug-version
- name: Extract download
unarchive:
src: "{{ app_rel_uri }}"
remote_src: true
dest: /usr/local/
register: app_download
tags:
- extract
- name: Download JuiceShop config file
get_url:
url: "{{ app_custom_config }}"
dest: "{{ node_app_dir }}config/devsecops.yml"
force: true
tags:
- get_config
- name: Install Forever
npm:
name: forever
global: yes
state: present
tags:
- run_app
- name: Force NodeJS to bind to IPV4
replace:
path: "{{ node_app_dir }}server.js"
regexp: '^.*\bserver\.listen\b.*$'
replace: server.listen(process.env.PORT || config.get('server.port'), "0.0.0.0", () => {
tags:
- deploy-app
- ipv4
- name: Check list of running Node.js apps.
command: forever list
register: forever_list
changed_when: false
tags:
- run-app
- name: Run application
shell: "NODE_ENV=devsecops forever start app.js"
args:
chdir: "{{ node_app_dir }}"
when: "forever_list.stdout.find('app.js') == -1"
tags:
- run-app