Puppet Class: jboss::internal::package
- Inherits:
- jboss::params
- Defined in:
- manifests/internal/package.pp
Overview
Internal class that installs JBoss
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 |
# File 'manifests/internal/package.pp', line 2
class jboss::internal::package (
$download_url,
$prerequisites,
$jboss_user,
$jboss_group,
$product = $jboss::params::product,
$version = $jboss::params::version,
$java_autoinstall = $jboss::params::java_autoinstall,
$java_version = $jboss::params::java_version,
$java_package = $jboss::params::java_package,
$install_dir = $jboss::params::install_dir,
# Prerequisites class, that can be overwritten
) inherits jboss::params {
include jboss
include jboss::internal::runtime
include jboss::internal::compatibility
$download_rootdir = $jboss::internal::params::download_rootdir
$download_file = jboss_basename($download_url)
$download_dir = "${download_rootdir}/download-${product}-${version}"
$home = $jboss::home
$configfile = $jboss::internal::runtime::configfile
$standaloneconfigfile = $jboss::internal::runtime::standaloneconfigfile
case $version {
/^[0-9]+\.[0-9]+\.[0-9]+[\._-][0-9a-zA-Z_-]+$/: {
debug("Running in version: ${1} -> ${version}")
}
default: {
fail("Invalid Jboss version passed: `${version}`! Pass valid version for ex.: `6.2.0.GA`")
}
}
anchor { 'jboss::package::begin':
require => Anchor['jboss::begin'],
}
File {
owner => $jboss_user,
group => $jboss_group,
mode => '2750',
}
Exec {
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
logoutput => 'on_failure',
}
if (!defined(Group[$jboss_group])) {
group { $jboss_group: ensure => 'present', }
}
if (!defined(User[$jboss_user])) {
$empty = ''
create_resources('user', {
"${jboss_user}${empty}" => {
ensure => 'present',
managehome => true,
gid => $jboss_group,
}
})
}
$confdir = "/etc/${product}"
file { $confdir:
ensure => 'directory',
alias => 'jboss::confdir',
owner => 'root',
group => 'root',
mode => '0755',
}
if $java_autoinstall {
class { 'java':
distribution => 'jdk',
version => $java_version,
package => $java_package,
notify => Service[$jboss::product],
}
Class['java'] -> Exec['jboss::package::check-for-java']
}
file { $download_dir:
ensure => 'directory',
}
jboss::internal::util::fetch::file { $download_file:
address => $download_url,
fetch_dir => $download_dir,
require => File[$download_dir],
}
if $prerequisites == Class['jboss::internal::prerequisites'] {
include jboss::internal::prerequisites
}
exec { 'jboss::unzip-downloaded':
command => "unzip -o -q ${download_dir}/${download_file} -d ${jboss::home}",
cwd => $download_dir,
creates => $jboss::home,
require => [
$prerequisites, # Prerequisites class, that can be overwritten
Jboss::Internal::Util::Fetch::File[$download_file],
Package['unzip'],
],
}
exec { 'jboss::move-unzipped':
command => "mv ${jboss::home}/*/* ${jboss::home}/",
creates => "${jboss::home}/bin",
require => Exec['jboss::unzip-downloaded'],
}
exec { 'jboss::test-extraction':
command => "echo '${jboss::home}/bin/init.d not found!' 1>&2 && exit 1",
unless => "test -d ${jboss::home}/bin/init.d",
require => Exec['jboss::move-unzipped'],
}
jboss::internal::util::groupaccess { $jboss::home:
user => $jboss_user,
group => $jboss_group,
require => [
User[$jboss_user],
Exec['jboss::test-extraction'],
],
}
file { "${confdir}/domain.xml":
ensure => 'link',
alias => 'jboss::configuration-link::domain',
target => "${jboss::home}/domain/configuration/domain.xml",
require => Jboss::Internal::Util::Groupaccess[$jboss::home],
}
$hostfile = 'host.xml'
file { "${confdir}/${hostfile}":
ensure => 'link',
alias => 'jboss::configuration-link::host',
target => "${jboss::home}/domain/configuration/${hostfile}",
require => Jboss::Internal::Util::Groupaccess[$jboss::home],
}
file { "${confdir}/standalone.xml":
ensure => 'link',
alias => 'jboss::configuration-link::standalone',
target => "${jboss::home}/standalone/configuration/${standaloneconfigfile}",
require => Jboss::Internal::Util::Groupaccess[$jboss::home],
}
file { "/etc/init.d/${product}":
ensure => 'link',
alias => 'jboss::service-link',
target => $jboss::internal::compatibility::initd_file,
require => Jboss::Internal::Util::Groupaccess[$jboss::home],
}
file { "/usr/bin/${jboss::internal::compatibility::product_short}-cli":
ensure => 'file',
alias => 'jboss::jbosscli',
content => template('jboss/jboss-cli.erb'),
mode => '0755',
require => Jboss::Internal::Util::Groupaccess[$jboss::home],
}
exec { 'jboss::package::check-for-java':
command => 'echo "Please provide Java executable to system!" 1>&2 && exit 1',
unless => '[ `which java` ] && java -version 2>&1 | grep -q \'java version\'',
require => Anchor['jboss::installed'],
before => Anchor['jboss::package::end'],
}
anchor { 'jboss::installed':
require => [
Jboss::Internal::Util::Groupaccess[$jboss::home],
Exec['jboss::test-extraction'],
File['jboss::confdir'],
File['jboss::logfile'],
File['jboss::jbosscli'],
File['jboss::service-link'],
],
before => Anchor['jboss::package::end'],
}
anchor { 'jboss::package::end': }
}
|