-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.yaml
More file actions
49 lines (39 loc) · 1.22 KB
/
deploy.yaml
File metadata and controls
49 lines (39 loc) · 1.22 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
---
- hosts: webservers
become: true
remote_user: ec2-user
tasks:
- name: setup nodejs repo
shell: curl --silent --location | bash -
#setting up nodejs repo and then comes installation of nodejs
- name: yum clean all
shell: yum clean all
ignore_errors: yes
#cleaning yum cache
- name: Install node.js
yum:
name: nodejs
state: latest #make sure EC2 has the latest version of nodejs
#Install nodejs
- name: Check whether rc.local contains server start up command
command: grep node /etc/rc.d/rc.local
register: checkmyconf
ignore_errors: yes
- name: Add node if it does not exist
shell: echo 'node /main.js &' >> /etc/rc.d/rc.local
when: checkmyconf.rc == 1
- name: Changing perm of /etc/rc.d/rc.local, adding "+x"
file: dest=/etc/rc.d/rc.local mode=a+x
- name: Move main.js to webserver
copy:
src: main.js
dest: /main.js
owner: ec2-user
group: ec2-user
mode: '0644'
follow: no
- name: reboot the server
shell: 'sleep 1 && shutdown -r now "Reboot triggered by Ansible" && sleep 1'
async: 1
poll: 0
become: true