-
-
Save ulinkwo/7750146 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class tomcat { | |
$tomcat_url = "http://mirrors.axint.net/apache/tomcat/tomcat-7/v7.0.25/bin/apache-tomcat-7.0.25.tar.gz" | |
$jdk_url = "http://download.oracle.com/otn-pub/java/jdk/6u25-b06/jdk-6u25-linux-x64.bin" | |
Exec { | |
path => "${::path}", | |
} | |
group { "puppet": | |
ensure => present, | |
} | |
package { "acpid": | |
ensure => installed, | |
} | |
package { "supervisor": | |
ensure => installed, | |
} | |
package { "wget": | |
ensure => installed, | |
} | |
exec { "tomcat::get_jdk": | |
cwd => "/tmp", | |
command => "wget ${jdk_url} -O jdk.bin > /root/.tomcat_get_jdk", | |
creates => "/root/.tomcat_get_jdk", | |
timeout => 900, | |
require => Package["wget"], | |
notify => Exec["tomcat::extract_jdk"], | |
} | |
exec { "tomcat::extract_jdk": | |
cwd => "/opt", | |
command => "sh /tmp/jdk.bin ; mv jdk* java", | |
creates => "/opt/java", | |
require => Exec["tomcat::get_jdk"], | |
refreshonly => true, | |
} | |
file { "/etc/environment": | |
ensure => present, | |
content => "JAVA_HOME=/opt/java | |
PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/java/bin\"", | |
} | |
user { "tomcat": | |
ensure => present, | |
comment => "Tomcat User", | |
home => "/opt/tomcat", | |
shell => "/bin/bash", | |
} | |
exec { "tomcat::get_tomcat": | |
cwd => "/tmp", | |
command => "wget ${tomcat_url} -O tomcat.tar.gz > /root/.tomcat_get_tomcat", | |
creates => "/root/.tomcat_get_tomcat", | |
timeout => 900, | |
require => Package["wget"], | |
notify => Exec["tomcat::extract_tomcat"], | |
} | |
exec { "tomcat::extract_tomcat": | |
cwd => "/opt", | |
command => "tar zxf /tmp/tomcat.tar.gz ; mv apache* tomcat", | |
creates => "/opt/tomcat", | |
require => Exec["tomcat::get_tomcat"], | |
refreshonly => true, | |
} | |
file { "/opt/tomcat/conf/tomcat-users.xml": | |
ensure => present, | |
content => "<?xml version='1.0' encoding='utf-8'?> | |
<tomcat-users> | |
<user username=\"admin\" password=\"tomcat\" roles=\"manager-gui\"/> | |
</tomcat-users>", | |
require => Exec["tomcat::extract_tomcat"], | |
} | |
file { "/opt/tomcat": | |
ensure => directory, | |
owner => "tomcat", | |
mode => 0755, | |
recurse => true, | |
require => Exec["tomcat::extract_tomcat"], | |
} | |
file { "/etc/supervisor/conf.d/tomcat.conf": | |
ensure => present, | |
content => "[program:tomcat] | |
command=/opt/tomcat/bin/catalina.sh run | |
environment=JAVA_HOME=\"/opt/java\",JAVA_OPTS=\"-Xms512m -Xmx512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled\" | |
directory=/opt/tomcat/bin | |
autostart=no | |
user=tomcat | |
stopsignal=QUIT", | |
require => [ Package["supervisor"], File["/opt/tomcat/conf/tomcat-users.xml"] ], | |
notify => Exec["tomcat::update_supervisor"], | |
} | |
exec { "tomcat::update_supervisor": | |
command => "supervisorctl update", | |
refreshonly => true, | |
} | |
} | |
include tomcat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment