-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava_tomcat_code_puppet2.pp
49 lines (46 loc) · 1.25 KB
/
java_tomcat_code_puppet2.pp
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
#install java
class tomcat {
group{'tomcat':
name =>'tomcat',
ensure => present,
}
user{'tomcat':
name =>'tomcat',
ensure => present,
groups => 'tomcat',
require => Group['tomcat'],
}
exec {'gettomcat':
path => '/bin:/usr/sbin:/usr/bin:/sbin',
command => 'wget http://www-eu.apache.org/dist/tomcat/tomcat-8/v8.5.8/bin/apache-tomcat-8.5.8.tar.gz',
cwd => '/tmp',
require => Exec['install'],
}
exec {'extracttomcat':
path => '/bin:/usr/sbin:/usr/bin:/sbin',
cwd => '/tmp',
command => 'mkdir -p /opt/tomcat && tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1',
require => Exec['gettomcat'],
}
exec { 'startTomcat':
path => '/bin:/usr/sbin:/usr/bin:/sbin',
require => [ Exec['extracttomcat'], User['tomcat'] ] ,
command => 'chgrp -R tomcat /opt/tomcat && /opt/tomcat/bin/startup.sh',
cwd =>'/opt/tomcat/bin',
}
}
class java {
if $::osfamily == 'Debian' {
# Needed for update-java-alternatives
package { 'java-common':
ensure => present,
notify => Exec['install'],
}
}
exec { 'install':
path => '/bin:/usr/sbin:/usr/bin:/sbin',
command => 'add-apt-repository -y ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk',
user => 'root',
}
}
class {'java':}->class{'tomcat':}