Skip to content

Commit

Permalink
Compatibility enhancement and modularization, tested on Ubuntu 16.04 …
Browse files Browse the repository at this point in the history
…with WildFly 10 refers to issue #73
  • Loading branch information
Suszyński Krzysztof committed Jun 22, 2016
1 parent 1c7f2e0 commit 5d14ea5
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 30 deletions.
55 changes: 28 additions & 27 deletions manifests/internal/compatibility.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,44 @@
class jboss::internal::compatibility {
include jboss

if $::osfamily != 'RedHat' and $::osfamily != 'Debian' {
fail("Unsupported OS family: ${::osfamily}. Supporting only RHEL and Debian systems. Consult README file.")
}

case $jboss::product {
'wildfly': {
if versioncmp($jboss::version, '8.0.0') < 0 or versioncmp($jboss::version, '10.0.0') >= 0 {
fail("Unsupported version ${jboss::product} ${jboss::version}. Supporting only: Wildfly 8.x and 9.x series")
}
include jboss::internal::compatibility::wildfly

$controller_port = $jboss::internal::compatibility::wildfly::controller_port
$product_short = $jboss::internal::compatibility::wildfly::product_short
$initd_file = $jboss::internal::compatibility::wildfly::initd_file
$systemd_file = $jboss::internal::compatibility::wildfly::systemd_file
$systemd_launcher = $jboss::internal::compatibility::wildfly::systemd_launcher
$initsystem = $jboss::internal::compatibility::wildfly::initsystem
}
'jboss-eap': {
if versioncmp($jboss::version, '6.0.0') < 0 or versioncmp($jboss::version, '8.0.0') >= 0 {
fail("Unsupported version ${jboss::product} ${jboss::version}. Supporting only: JBoss EAP 6.x and 7.x series")
}
include jboss::internal::compatibility::eap

$controller_port = $jboss::internal::compatibility::eap::controller_port
$product_short = $jboss::internal::compatibility::eap::product_short
$initd_file = $jboss::internal::compatibility::eap::initd_file
$systemd_file = $jboss::internal::compatibility::eap::systemd_file
$systemd_launcher = $jboss::internal::compatibility::eap::systemd_launcher
$initsystem = $jboss::internal::compatibility::eap::initsystem
}
'jboss-as': {
if versioncmp($jboss::version, '7.0.0') < 0 or versioncmp($jboss::version, '8.0.0') >= 0 {
fail("Unsupported version ${jboss::product} ${jboss::version}. Supporting only: JBoss AS 7.x series")
}
include jboss::internal::compatibility::as

$controller_port = $jboss::internal::compatibility::as::controller_port
$product_short = $jboss::internal::compatibility::as::product_short
$initd_file = $jboss::internal::compatibility::as::initd_file
$systemd_file = $jboss::internal::compatibility::as::systemd_file
$systemd_launcher = $jboss::internal::compatibility::as::systemd_launcher
$initsystem = $jboss::internal::compatibility::as::initsystem
}
default: {
fail("Unsupported product ${jboss::product}. Supporting only: 'jboss-eap', 'jboss-as' and 'wildfly'")
}
}

case $jboss::product {
'wildfly': {
$controller_port = '9990'
$__osfamily_down = downcase($::osfamily)
$initd_file = "${jboss::home}/bin/init.d/wildfly-init-${__osfamily_down}.sh"
$product_short = 'wildfly'
}
'jboss-eap', 'jboss-as': {
$controller_port = '9999'
$product_short = 'jboss'
$initd_file = $jboss::runasdomain ? {
true => "${jboss::home}/bin/init.d/jboss-as-domain.sh",
default => "${jboss::home}/bin/init.d/jboss-as-standalone.sh",
}
}
default: {}
}

}
18 changes: 18 additions & 0 deletions manifests/internal/compatibility/as.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# == Class: jboss::internal::compatibility::as
# This is internal class to resolve JBoss AS compatibility
class jboss::internal::compatibility::as {
include jboss

if versioncmp($jboss::version, '7.0.0') < 0 or versioncmp($jboss::version, '8.0.0') >= 0 {
fail("Unsupported version ${jboss::product} ${jboss::version}. Supporting only: JBoss AS 7.x series")
}
$systemd_file = undef
$systemd_launcher = undef
$initsystem = 'SystemV'
$controller_port = '9999'
$product_short = 'jboss'
$initd_file = $jboss::runasdomain ? {
true => "${jboss::home}/bin/init.d/jboss-as-domain.sh",
default => "${jboss::home}/bin/init.d/jboss-as-standalone.sh",
}
}
5 changes: 5 additions & 0 deletions manifests/internal/compatibility/common.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# == Class: jboss::internal::compatibility::common
# This is internal class to resolve common compatibility variables
class jboss::internal::compatibility::common {
$osfamily_down = downcase($::osfamily)
}
32 changes: 32 additions & 0 deletions manifests/internal/compatibility/eap.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# == Class: jboss::internal::compatibility::eap
# This is internal class to resolve JBoss EAP compatibility
class jboss::internal::compatibility::eap {
include jboss

if versioncmp($jboss::version, '6.0.0') < 0 or versioncmp($jboss::version, '8.0.0') >= 0 {
fail("Unsupported version ${jboss::product} ${jboss::version}. Supporting only: JBoss EAP 6.x and 7.x series")
}

$systemd_file = undef
$systemd_launcher = undef
$initsystem = 'SystemV'

$_eap_after7x = ( versioncmp($jboss::version, '7.0.0') >= 0 )
if $_eap_after7x and $::osfamily != 'RedHat' {
fail("Jboss EAP 7.x is supported only on RHEL systems, but tried on ${::osfamily}!")
}
$initsystem = 'SystemV'
$product_short = 'jboss'
if $_eap_after7x {
# after EAP 7.x
$controller_port = '9990'
$initd_file = "${jboss::home}/bin/init.d/jboss-eap-rhel.sh"
} else {
# before EAP 7.x
$controller_port = '9999'
$initd_file = $jboss::runasdomain ? {
true => "${jboss::home}/bin/init.d/jboss-as-domain.sh",
default => "${jboss::home}/bin/init.d/jboss-as-standalone.sh",
}
}
}
61 changes: 61 additions & 0 deletions manifests/internal/compatibility/wildfly.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# == Class: jboss::internal::compatibility::wildfly
# This is internal class to resolve Wildfly compatibility
class jboss::internal::compatibility::wildfly {
include jboss
include jboss::internal::compatibility::common
$_osfamily_down = $jboss::internal::compatibility::common::osfamily_down

if versioncmp($jboss::version, '8.0.0') < 0 or versioncmp($jboss::version, '11.0.0') >= 0 {
fail("Unsupported version ${jboss::product} ${jboss::version}. Supporting only: Wildfly 8.x, 9.x and 10.x series")
}
$controller_port = '9990'
$product_short = 'wildfly'

if versioncmp($jboss::version, '10.0.0') >= 0 {
# after WFly 10.x
$initd_file = "${jboss::home}/docs/contrib/scripts/init.d/wildfly-init-${_osfamily_down}.sh"
$systemd_file = "${jboss::home}/docs/contrib/scripts/systemd/wildfly.service"
$systemd_launcher = "${jboss::home}/docs/contrib/scripts/systemd/launch.sh"
case $::osfamily {
'RedHat': {
case $::operatingsystem {
'RedHat', 'CentOS', 'OracleLinux', 'Scientific', 'OEL': {
if (versioncmp($::operatingsystemrelease, '7.0') > 0) {
$initsystem = 'SystemD'
} else {
$initsystem = 'SystemV'
}
}
'Fedora': {
if (versioncmp($::operatingsystemrelease, '21') > 0) {
$initsystem = 'SystemD'
} else {
$initsystem = 'SystemV'
}
}
default: {
fail("Unsupported OS: ${::operatingsystem}")
}
}
}
'Debian': {
case $::lsbdistcodename {
'lenny','squeeze','lucid','natty','wheezy','precise','quantal','raring','saucy','trusty','utopic' : {
$initsystem = 'SystemV'
}
'jessie','vivid','wily','xenial': {
$initsystem = 'SystemD'
}
default: { fail("Unsupported release ${::lsbdistcodename}") }
}
}
default: {
fail("Unsupported OS family: ${::osfamily}. Supporting only RHEL and Debian systems. Consult README file.")
}
}
} else {
# for WFly 8.x, 9.x
$initsystem = 'SystemV'
$initd_file = "${jboss::home}/bin/init.d/wildfly-init-${_osfamily_down}.sh"
}
}
7 changes: 4 additions & 3 deletions manifests/internal/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@
require => Exec['jboss::unzip-downloaded'],
}

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

Expand Down Expand Up @@ -172,7 +173,7 @@

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\'',
unless => '[ `which java` ] && java -version 2>&1 | grep -qE \'(jdk|jre|java) version\'',
require => Anchor['jboss::installed'],
before => Anchor['jboss::package::end'],
}
Expand Down
19 changes: 19 additions & 0 deletions spec/acceptance/jboss/wildfly10_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper_acceptance'

describe 'jboss::wildfly10 smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :'jboss::wildfly10' }

it 'should add install WildFly 10 with no errors' do
apply_manifest(pp, :expect_changes => true, :trace => true)
end
it 'should work idempotently' do
apply_manifest(pp, :catch_changes => true, :trace => true)
end
describe service('wildfly') do
it { is_expected.to be_running }
end
after(:all) do
extend Testing::Acceptance::Cleaner
remove_jboss_installation('wildfly')
end
end

0 comments on commit 5d14ea5

Please sign in to comment.