This repository has been archived by the owner on Dec 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrecipe.rb
98 lines (86 loc) · 1.86 KB
/
recipe.rb
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
97
98
HOST = node[:hostname]
USER = 'isucon'
ISU01 = 'ip-192-168-0-11'
ISU02 = 'ip-192-168-0-12'
ISU03 = 'ip-192-168-0-13'
MItamae::ResourceContext.class_eval do
def enable_if(b)
if b
%i[enable start]
else
%i[disable stop]
end
end
end
if HOST == ISU01
service 'isuride-go.service' do
action %i[enable start]
end
service 'isuride-matcher.service' do
action %i[enable start]
end
service 'isuride-payment_mock.service' do
action %i[enable start]
end
else
service 'isuride-go.service' do
action %i[disable stop]
end
service 'isuride-matcher.service' do
action %i[disable stop]
end
service 'isuride-payment_mock.service' do
action %i[disable stop]
end
end
if HOST == ISU02
service 'mysql.service' do
action %i[enable start]
end
else
service 'mysql.service' do
action %i[disable stop]
end
end
if HOST == ISU01
service 'nginx.service' do
action %i[enable start]
end
else
service 'nginx.service' do
action %i[disable stop]
end
end
#package 'redis'
#service 'redis' do
# action %i[enable start]
#end
{
'nginx' => '/etc/nginx/nginx.conf',
'mysql' => '/etc/mysql/mysql.conf.d/mysqld.cnf',
'isuride-go.service' => '/etc/systemd/system/isuride-go.service',
}.each do |service, conf|
conf_source = "./#{HOST}/#{File.basename conf}"
next unless File.file? conf_source
remote_file conf do
source conf_source
mode '0644'
end
end
###
# Monitoring tools
###
execute 'install netdata' do
command 'bash -c "bash <(curl -SLs https://my-netdata.io/kickstart.sh) all --non-interactive --stable-channel --no-updates --disable-telemetry"'
not_if "systemctl list-unit-files | grep '^netdata.service'"
end
service 'netdata' do
action %i[disable stop]
end
service 'snap.amazon-ssm-agent.amazon-ssm-agent.service' do
action %i[disable stop]
end
service 'snapd.service' do
action %i[disable stop]
end
package 'percona-toolkit'