-
Notifications
You must be signed in to change notification settings - Fork 1
/
commands.sh
61 lines (44 loc) · 1.18 KB
/
commands.sh
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
mkdir cookbooks
chef generate cookbook cookbooks/tomcat
tree cookbooks/tomcat
echo "
package 'java-1.7.0-openjdk-devel'
group 'chef' do
action :create
end
user 'chef' do
group 'chef'
end
# remote_file '/tmp/apache-tomcat-8.0.33.tar.gz' do
# source 'http://mirror.sdunix.com/apache/tomcat/tomcat-8/v8.0.33/bin/apache-tomcat-8.0.33.tar.gz'
# end
directory '/opt/tomcat' do
action :create
recursive true
end
execute 'extract_tomcat' do
command 'tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1'
cwd '/tmp'
end
execute 'chgrp -R chef /opt/tomcat/conf'
directory '/opt/tomcat/conf' do
group 'chef'
mode '0474'
end
execute 'chmod g+r conf/*' do
cwd '/opt/tomcat'
end
execute 'chown -R chef webapps/ work/ temp/ logs/ conf/' do
cwd '/opt/tomcat'
end
template '/etc/systemd/system/tomcat.service' do
source 'tomcat.service.erb'
end
execute 'systemctl daemon-reload'
service 'tomcat' do
action [:start, :enable]
end
" > cookbooks/tomcat/recipes/default.rb
chef generate template cookbooks/tomcat tomcat.service
cp ~/tomcat.service ~/cookbooks/tomcat/templates/default/tomcat.service.erb
sudo chef-client --local-mode --runlist "recipe[tomcat::default]"