Puppet Class: jboss::internal::package

Inherits:
jboss::params
Defined in:
manifests/internal/package.pp

Overview

Internal class that installs JBoss

Parameters:

  • prerequisites (Any)
  • jboss_user (Any)
  • jboss_group (Any)
  • download_url (Any) (defaults to: $jboss::internal::runtime::download_url)
  • product (Any) (defaults to: $jboss::params::product)
  • version (Any) (defaults to: $jboss::params::version)
  • java_autoinstall (Any) (defaults to: $jboss::params::java_autoinstall)
  • java_version (Any) (defaults to: $jboss::params::java_version)
  • java_package (Any) (defaults to: $jboss::params::java_package)
  • install_dir (Any) (defaults to: $jboss::params::install_dir)
  • java_dist (Any) (defaults to: $jboss::params::java_dist)


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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'manifests/internal/package.pp', line 2

class jboss::internal::package (
  $prerequisites,
  $jboss_user,
  $jboss_group,
  $download_url     = $jboss::internal::runtime::download_url,
  $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,
  $java_dist        = $jboss::params::java_dist,
  # Prerequisites class, that can be overwritten
) inherits jboss::params {
  include jboss
  include jboss::internal::runtime
  include jboss::internal::params
  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      => $jboss::internal::params::syspath,
    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 => $java_dist,
      version      => $java_version,
      package      => $java_package,
      notify       => Service[$jboss::product],
    }
    Class['java'] -> Exec['jboss::package::check-for-java']
  }

  file { $download_dir:
    ensure => 'directory',
  }

  if $download_file == undef {
    fail Puppet::Error, 'Download_url cannot be undef'
  }

  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'],
  }

  $extract_testfile = 'bin/jboss-cli.sh'
  exec { 'jboss::test-extraction':
    command => "echo '${jboss::home}/${extract_testfile} not found!' 1>&2 && exit 1",
    unless  => "test -f ${jboss::home}/${extract_testfile}",
    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],
  }

  if $jboss::internal::compatibility::initsystem == 'SystemD' {
    file { "${jboss::home}/bin/launch.sh":
      ensure  => 'file',
      alias   => 'jboss::systemd_launcher',
      mode    => '0755',
      content => template($jboss::internal::compatibility::systemd_launcher),
      notify  => Anchor['jboss::installed'],
      require => Jboss::Internal::Util::Groupaccess[$jboss::home],
    }
    file { "${jboss::home}/bin/wait-for-start.sh":
      ensure  => 'file',
      alias   => 'jboss::systemd_waiter',
      mode    => '0755',
      content => template('jboss/systemd/wait-for-start.sh'),
      notify  => Anchor['jboss::installed'],
      require => Jboss::Internal::Util::Groupaccess[$jboss::home],
    }
    file { "/etc/systemd/system/${product}.service":
      ensure  => 'file',
      alias   => 'jboss::service-link',
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => template($jboss::internal::compatibility::systemd_file),
      require => Jboss::Internal::Util::Groupaccess[$jboss::home],
    }
  } else {
    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 -qE \'(jdk|jre|java) version\'',
    require => Anchor['jboss::installed'],
    before  => Anchor['jboss::package::end'],
  }

  anchor { 'jboss::installed':
    notify    => Anchor['jboss::package::end'],
    subscribe => [
      Jboss::Internal::Util::Groupaccess[$jboss::home],
      Exec['jboss::test-extraction'],
      File['jboss::confdir'],
      File['jboss::logfile'],
      File['jboss::jbosscli'],
      File['jboss::service-link']
    ],
  }
  anchor { 'jboss::package::end': }
}