-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathhello.yml
51 lines (47 loc) · 1.2 KB
/
hello.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
# First Play
- name: Play - Handle Files in all hosts
hosts: all
tasks:
- name: all host are identified with a file
copy:
content: My family is {{ ansible_os_family }}
dest: /family.txt
mode: '777'
# Second play
- name: Play - for Alpines Nodejs app
hosts: app_group
tasks:
- name: NodeJs is installed
apk:
name: "{{ item }}"
update_cache: yes
state: latest
loop:
- nodejs
- nodejs-npm
- name: app directory is created
file:
path: /node-app
state: directory
- name: app is installed
template:
src: app.js.j2
dest: /node-app/app.js
- name: app dependencies file is copied
copy:
src: package.json
dest: /node-app/package.json
- name: app dependencies are installed
npm:
path: /node-app
state: present
production: true
- name: Install forever (to run Node.js app).
npm: name=forever global=yes state=present
- name: Check list of Node.js apps running.
command: forever list
register: forever_list
changed_when: false
- name: Start example Node.js app.
command: forever start /node-app/app.js
when: "forever_list.stdout.find('/node-app/app.js') == -1"