This repository has been archived by the owner on Sep 14, 2024. It is now read-only.
forked from itamae-kitchen/itamae
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.rb
213 lines (151 loc) · 3.25 KB
/
default.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
include_recipe "./included.rb"
include_recipe "./included.rb" # including the same recipe is expected to be skipped.
user "create itamae user" do
uid 123
username "itamae"
password "$1$ltOY8bZv$iZ57f1KAp8jwKViNm3pze."
home '/home/foo'
end
user "update itamae user" do
uid 1234
username "itamae"
password "$1$TQz9gPMl$nHYrsA5W2ZdZ0Yn021BQH1"
home '/home/itamae'
end
######
package 'dstat' do
action :install
end
package 'sl' do
version '3.03-17'
end
######
package "ruby"
gem_package 'tzinfo' do
version '1.1.0'
end
gem_package 'tzinfo' do
version '1.2.2'
end
######
execute "echo -n > /tmp/notifies"
execute "echo -n 1 >> /tmp/notifies" do
action :nothing
end
execute "echo -n 2 >> /tmp/notifies" do
notifies :run, "execute[echo -n 1 >> /tmp/notifies]"
end
execute "echo -n 3 >> /tmp/notifies" do
action :nothing
end
execute "echo -n 4 >> /tmp/notifies" do
notifies :run, "execute[echo -n 3 >> /tmp/notifies]", :immediately
end
######
execute "echo -n > /tmp/subscribes"
execute "echo -n 1 >> /tmp/subscribes" do
action :nothing
subscribes :run, "execute[echo -n 2 >> /tmp/subscribes]"
end
execute "echo -n 2 >> /tmp/subscribes"
execute "echo -n 3 >> /tmp/subscribes" do
action :nothing
subscribes :run, "execute[echo -n 4 >> /tmp/subscribes]", :immediately
end
execute "echo -n 4 >> /tmp/subscribes"
######
remote_file "/tmp/remote_file" do
source "hello.txt"
end
directory "/tmp/directory" do
mode "700"
owner "itamae"
group "itamae"
end
template "/tmp/template" do
source "hello.erb"
variables(goodbye: "Good bye")
end
file "/tmp/file" do
content "Hello World"
mode "777"
end
execute "echo 'Hello Execute' > /tmp/execute"
file "/tmp/never_exist1" do
only_if "exit 1"
end
file "/tmp/never_exist2" do
not_if "exit 0"
end
######
service "cron" do
action :stop
end
execute "ps -C cron > /tmp/cron_stopped; true"
service "cron" do
action :start
end
execute "ps -C cron > /tmp/cron_running; true"
######
package "nginx" do
options "--force-yes"
end
service "nginx" do
action [:enable, :start]
end
execute "test -f /etc/rc3.d/S20nginx" # test
execute "test $(ps h -C nginx | wc -l) -gt 0" # test
service "nginx" do
action [:disable, :stop]
end
execute "test ! -f /etc/rc3.d/S20nginx" # test
execute "test $(ps h -C nginx | wc -l) -eq 0" # test
######
link "/tmp-link" do
to "/tmp"
end
#####
local_ruby_block "greeting" do
block do
Itamae::Logger.info "板前"
end
end
#####
package "git"
git "/tmp/git_repo" do
repository "https://github.com/ryotarai/infrataster.git"
revision "v0.1.0"
end
#####
execute "echo Hello > /tmp/created_by_itamae_user" do
user "itamae"
end
#####
execute "echo 'notify to resource in default2.rb'" do
notifies :create, "file[put file in default2.rb]"
end
#####
file "/tmp/never_exist3" do
action :create
end
file "/tmp/never_exist3" do
action :delete
end
#####
define :definition_example, key: 'default' do
execute "echo 'name:#{params[:name]},key:#{params[:key]}' > /tmp/created_by_definition"
end
definition_example "name" do
key 'value'
end
#####
file "/tmp/never_exist4" do
action :nothing
end
file "/tmp/file1" do
content "Hello, World"
end
file "/tmp/file1" do
content "Hello, World"
notifies :create, "file[/tmp/never_exist4]"
end