From 0e33e42a57db49da137e7330cc0e4b66d0fb80bc Mon Sep 17 00:00:00 2001 From: Jarkko Oranen Date: Fri, 16 Apr 2021 18:19:37 +0300 Subject: [PATCH 1/3] Provide option to install a java package directly via this module --- README.md | 37 ++++++++++++++++++++------------ manifests/init.pp | 1 + manifests/install.pp | 6 ++++++ spec/classes/jira_config_spec.rb | 12 +++++++++++ 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 862e39bc..2d8c9ddc 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ connector directory from mysql.com as per Atlassian's documented recommendations ### Beginning with JIRA -This puppet module will automatically download the JIRA zip from Atlassian and +This puppet module will automatically download the JIRA archive from Atlassian and extracts it into /opt/jira/atlassian-jira-$version. The default JIRA home is /home/jira. @@ -78,8 +78,20 @@ If you would prefer to use Hiera then see jira.yaml file for available options. #### Basic example ```puppet + # Java 11 is managed externally and installed in /opt/java class { 'jira': - javahome => '/opt/java', + javahome => '/opt/java', + } +``` + +The module can install a package for you using your OS's package manager. +Note that there's no smarts here. You need to set javahome correctly. + +```puppet + # this example works on RHEL + class { 'jira': + java_package => 'java-11-openjdk-headless' + javahome => '/usr/lib/jvm/jre-11-opendjk/', } ``` @@ -94,22 +106,13 @@ The jira::facts class is required for upgrades. ```puppet class { 'jira': - javahome => '/opt/java', - version => '8.13.5', + java_package => 'java-11-openjdk-headless' + javahome => '/usr/lib/jvm/jre-11-opendjk/', + version => '8.16.0', } class { 'jira::facts': } ``` -##### Upgrades to the JIRA puppet Module - -puppet-archive is the default module for -deploying the JIRA binaries. - -```puppet - class { 'jira': - javahome => '/opt/java', - } -``` ## Reference @@ -359,6 +362,11 @@ Defaults to `http://cdn.mysql.com/Downloads/Connector-J` The `JAVA_HOME` directory, defaults to undef. This is a *required* parameter +##### `$java_package` + +If defined, the module will install this package before it runs the JIRA service. +Defaults to undef. + ##### `$jvm_xms` The initial memory allocation pool for a Java Virtual Machine. @@ -593,6 +601,7 @@ Some more crowd.properties for SSO, see atlassian documentation for details group => 'jira', dbpassword => 'secret', dbserver => 'localhost', + java_package => 'java-11-openjdk-headless', javahome => '/usr/lib/jvm/jre-11-openjdk/', download_url => 'http://myserver/pub/development-tools/atlassian/', tomcat_additional_connectors => { diff --git a/manifests/init.pp b/manifests/init.pp index 75ef6ea1..2d20cbf7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -83,6 +83,7 @@ Optional[Boolean] $pool_test_while_idle = undef, Optional[Boolean] $pool_test_on_borrow = undef, # JVM Settings + Optional[String] $java_package = undef, Optional[Stdlib::AbsolutePath] $javahome = undef, Jira::Jvm_types $jvm_type = 'openjdk-11', String $jvm_xms = '256m', diff --git a/manifests/install.pp b/manifests/install.pp index 5cb1b11b..43ade6e0 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -48,6 +48,12 @@ } } + if $jira::java_package { + package { $jira::java_package: + ensure => 'present', + } + } + $file = "atlassian-${jira::product_name}-${jira::version}.tar.gz" # webappdir is defined in init.pp because other things depend on it. diff --git a/spec/classes/jira_config_spec.rb b/spec/classes/jira_config_spec.rb index 3664875e..11f24480 100644 --- a/spec/classes/jira_config_spec.rb +++ b/spec/classes/jira_config_spec.rb @@ -35,6 +35,18 @@ it { is_expected.not_to contain_file('/opt/jira/atlassian-jira-software-8.13.5-standalone/bin/check-java.sh') } end + context 'default params with java install' do + let(:params) do + { + javahome: '/usr/lib/jvm/jre-11-openjdk', + java_package: 'java-11-openjdk-headless', + } + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_package('java-11-openjdk-headless') } + end + context 'database settings' do let(:params) do { From 753d2f0aedcc4a89b1c532f449894f558ad6a434 Mon Sep 17 00:00:00 2001 From: Jarkko Oranen Date: Fri, 16 Apr 2021 18:38:59 +0300 Subject: [PATCH 2/3] Adapt acceptance test for testing with openjdk-11. Leave MySQL test to test for 1.8 still --- spec/acceptance/default_parameters_spec.rb | 15 +++++++++++---- spec/acceptance/mysql_spec.rb | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/default_parameters_spec.rb b/spec/acceptance/default_parameters_spec.rb index 50e23646..2b3209d6 100644 --- a/spec/acceptance/default_parameters_spec.rb +++ b/spec/acceptance/default_parameters_spec.rb @@ -3,8 +3,14 @@ describe 'jira postgresql' do it 'installs with defaults' do pp = <<-EOS - class { 'java': - distribution => 'jre', + $java_package = $facts['os']['family'] ? { + 'RedHat' => 'java-11-openjdk-headless', + 'Debian' => 'openjdk-11-jre-headless', + } + + $java_home = $facts['os']['family'] ? { + 'RedHat' => '/usr/lib/jvm/jre-11-openjdk', + 'Debian' => '/usr/lib/jvm/java-1.11.0-openjdk-amd64', } class { 'postgresql::server': } @@ -15,8 +21,9 @@ class { 'postgresql::server': } } class { 'jira': - javahome => '/usr', - require => [Class['java'], Postgresql::Server::Db['jira']], + java_package => $java_package, + javahome => $java_home, + require => Postgresql::Server::Db['jira'], } class { 'jira::facts': } diff --git a/spec/acceptance/mysql_spec.rb b/spec/acceptance/mysql_spec.rb index 90ce2e13..ae0d2af5 100644 --- a/spec/acceptance/mysql_spec.rb +++ b/spec/acceptance/mysql_spec.rb @@ -38,6 +38,7 @@ class { 'jira': installdir => '/opt/atlassian-jira', homedir => '/opt/jira-home', javahome => '/usr', + jvm_type => 'oracle-jdk-1.8', db => 'mysql', dbport => 3306, dbdriver => 'com.mysql.jdbc.Driver', From fbc49c58fcf834a941fa8f1844b30508cc4f9248 Mon Sep 17 00:00:00 2001 From: Jarkko Oranen Date: Fri, 16 Apr 2021 18:40:13 +0300 Subject: [PATCH 3/3] Update manifests/init.pp Co-authored-by: Tim Meusel --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2d20cbf7..ab0ae0a6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -83,7 +83,7 @@ Optional[Boolean] $pool_test_while_idle = undef, Optional[Boolean] $pool_test_on_borrow = undef, # JVM Settings - Optional[String] $java_package = undef, + Optional[String[1]] $java_package = undef, Optional[Stdlib::AbsolutePath] $javahome = undef, Jira::Jvm_types $jvm_type = 'openjdk-11', String $jvm_xms = '256m',