-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployMon.yml
96 lines (82 loc) · 3.03 KB
/
deployMon.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
85
86
87
88
89
90
91
92
93
94
95
96
---
- name : Setup CS Monitor
hosts: csmon
roles:
gather_facts: False
become_method: sudo
vars_files: secrets.yml
vars:
home: /home/{{service_user}}
tasks:
- name: nodejs dload
get_url:
url: 'https://deb.nodesource.com/setup_8.x'
dest: '{{home}}/install.x'
mode: '0764'
- name: nodejs add
command: '{{home}}/install.x'
- name: install packages
apt:
pkg: ['nodejs', 'npm', 'git', 'screen']
update_cache: yes
cache_valid_time: 3600
state: present
- name: clone csmon
git:
repo: 'https://github.com/OpenSourceLAN/srcds-perfmon.git'
dest: '{{home}}/csmon'
become: yes
become_user: '{{service_user}}'
- name: copy indexes
copy:
src: '{{home}}/csmon/index.js'
dest: '{{home}}/csmon/{{item}}_index.js'
remote_src: yes
owner: '{{service_user}}'
loop: "{{group}}"
- name: change config sources
replace:
path: '{{home}}/csmon/{{item}}_index.js'
regexp: 'config.json'
replace: '{{item}}_config.json'
loop: "{{group}}"
- name: change ports
replace:
path: '{{home}}/csmon/{{item}}_index.js'
regexp: '9999'
replace: '{{10000 + index}}'
loop: "{{group}}"
loop_control:
index_var: index
- name: copy cfg template
template:
src: 'csmon/config.json.j2'
dest: '{{home}}/csmon/{{item}}_config.json'
owner: '{{service_user}}'
loop: "{{group}}"
- name: npm install
command: npm install
args:
chdir: '{{home}}/csmon'
become: yes
become_user: '{{service_user}}'
- name: copy run.sh template
template:
src: 'csmon/run.sh.j2'
dest: '{{home}}/csmon/run.sh'
owner: '{{service_user}}'
group: '{{service_user}}'
mode: 0755
- name: copy service templates
template:
src: 'csmon/csmon.service.j2'
dest: '/etc/systemd/system/{{item}}_csmon.service'
loop: "{{group}}"
- name: reload service
command: systemctl daemon-reload
- name: enable service
service:
name: '{{item}}_csmon'
state: started
enabled: True
loop: "{{group}}"