Puppet Class: tomcat::install
- Defined in:
- manifests/install.pp
Overview
Class: tomcat::install
This class installs tomcat. It should not be called directly.
Authors
-
Justin Lambert <jlambert@letsevenup.com>
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 |
# File 'manifests/install.pp', line 10
class tomcat::install {
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}
$install_dir = $::tomcat::install_dir
$sites_mode = $::disposition ? {
'dev' => '0777',
'vagrant' => '0777',
default => '0775',
}
if !defined(Package['unzip']) {
package { 'unzip': ensure => 'installed' }
}
group { 'tomcat':
ensure => 'present',
system => true,
}
user { 'tomcat':
ensure => present,
comment => 'Tomcat Service User',
system => true,
gid => 'tomcat',
home => "${install_dir}/tomcat",
shell => '/bin/bash',
managehome => false,
require => Group['tomcat'];
}
file { '/etc/init.d/tomcat':
ensure => file,
mode => '0555',
owner => root,
group => root,
content => template('tomcat/tomcat.init.erb'),
}
exec { 'fetch_tomcat':
command => "/usr/bin/curl -o apache-tomcat-${::tomcat::version}.tar.gz ${::tomcat::real_url}/apache-tomcat-${::tomcat::version}.tar.gz",
cwd => '/tmp',
creates => "/tmp/apache-tomcat-${::tomcat::version}.tar.gz",
path => '/usr/bin/:/bin',
logoutput => on_failure,
unless => "/usr/bin/test -d ${install_dir}/apache-tomcat-${::tomcat::version}",
}
exec { 'extract_tomcat':
command => "/bin/tar -xzf /tmp/apache-tomcat-${::tomcat::version}.tar.gz -C ${install_dir} && /bin/chown -R tomcat:tomcat ${install_dir}/apache-tomcat-${::tomcat::version} && rm -rf ${install_dir}/apache-tomcat-${::tomcat::version}/logs",
cwd => $install_dir,
creates => "${install_dir}/apache-tomcat-${::tomcat::version}",
path => '/bin/:/usr/bin/',
require => [Exec['fetch_tomcat'], User['tomcat']],
logoutput => on_failure,
}
file { "${$install_dir}/tomcat":
ensure => 'link',
target => "${install_dir}/apache-tomcat-${::tomcat::version}",
require => Exec['extract_tomcat'],
replace => $::tomcat::auto_upgrade,
notify => Class['tomcat::service'],
}
file { $::tomcat::sites_dir:
ensure => directory,
owner => tomcat,
group => tomcat,
mode => $sites_mode,
}
file { "${::tomcat::sites_dir}/logs":
ensure => link,
target => $::tomcat::log_dir,
}
file { $::tomcat::log_dir:
ensure => directory,
mode => '0644',
owner => tomcat,
group => tomcat,
}
file { "${install_dir}/tomcat/logs":
ensure => link,
target => $::tomcat::log_dir,
require => [File[$::tomcat::log_dir], Exec['extract_tomcat']],
}
# Remove the default tomcat apps
file { [ "${install_dir}/tomcat/webapps/docs",
"${install_dir}/tomcat/webapps/examples",
"${install_dir}/tomcat/webapps/ROOT",
"${install_dir}/tomcat/webapps/manager",
"${install_dir}/tomcat/webapps/host-manager" ]:
ensure => absent,
recurse => true,
purge => true,
force => true,
}
}
|