From b6c50d9e839be8f9cca7136b52aa223e3e8fbfb7 Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Sat, 17 Jan 2015 15:32:04 +0200 Subject: [PATCH 01/13] Add parameter stop_jira --- README.md | 3 +++ manifests/init.pp | 6 +++++- spec/classes/jira_upgrade_spec.rb | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8800ff1e..7d247393 100644 --- a/README.md +++ b/README.md @@ -291,6 +291,9 @@ Manage the JIRA service, defaults to 'running' Defaults to 'true' +#####`$stop_jira` +If the jira service is managed outside of puppet the stop_jira paramater can be used to shut down jira for upgrades. Defaults to 'service jira stop && sleep 15' + #####`$proxy = {}` Defaults to {}, See examples on how to use. diff --git a/manifests/init.pp b/manifests/init.pp index f2ecbb1c..7f8e6e2e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -90,6 +90,10 @@ $service_manage = true, $service_ensure = running, $service_enable = true, + # Command to stop jira in preparation to updgrade. This is configurable + # incase the jira service is managed outside of puppet. eg: using the + # puppetlabs-corosync module: 'crm resource stop jira && sleep 15' + $stop_jira = 'service jira stop && sleep 15', # Tomcat $tomcatPort = 8080, @@ -114,7 +118,7 @@ # Shut it down in preparation for upgrade. if versioncmp($version, $::jira_version) > 0 { notify { 'Attempting to upgrade JIRA': } - exec { 'service jira stop && sleep 15': before => Anchor['jira::start'] } + exec { $stop_jira: before => Anchor['jira::start'] } } } diff --git a/spec/classes/jira_upgrade_spec.rb b/spec/classes/jira_upgrade_spec.rb index 3f3bac2e..4d946903 100644 --- a/spec/classes/jira_upgrade_spec.rb +++ b/spec/classes/jira_upgrade_spec.rb @@ -11,5 +11,16 @@ }} it { should contain_exec('service jira stop && sleep 15') } end + context 'custom params' do + let(:params) {{ + :javahome => '/opt/java', + :stop_jira => 'stop service please' + }} + let(:facts) { { + :jira_version => "5.0.0", + }} + it { should contain_exec('stop service please') } + end + end end From 5455fafa5dcba4b0cb1dd888af65ea61e0a28e9b Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Sat, 17 Jan 2015 15:33:41 +0200 Subject: [PATCH 02/13] Fix bug on RHEL7 where updating the systemd script does not take effect without refreshing systemd * Fix bug on RHEL7 * Add tests for systemd on rhel 7 * Add tests for lockfile location --- manifests/service.pp | 16 ++++++++++++++-- spec/classes/jira_service_spec.rb | 24 ++++++++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/manifests/service.pp b/manifests/service.pp index dcf98e3e..610bdd62 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -29,14 +29,26 @@ file { $service_file_location: content => template($service_file_template), mode => '0755', - before => Service['jira'], } if $service_manage { + + validate_string($service_ensure) + validate_bool($service_enable) + + if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '7' { + exec { 'refresh_systemd': + command => 'systemctl daemon-reload', + refreshonly => true, + subscribe => File[$service_file_location], + before => Service['jira'], + } + } + service { 'jira': ensure => $service_ensure, enable => $service_enable, - require => Class['jira::config'], + require => File[$service_file_location], } } } diff --git a/spec/classes/jira_service_spec.rb b/spec/classes/jira_service_spec.rb index 109713ca..bcaa3d03 100644 --- a/spec/classes/jira_service_spec.rb +++ b/spec/classes/jira_service_spec.rb @@ -8,19 +8,34 @@ }} it { should contain_service('jira')} it { should contain_file('/etc/init.d/jira') - .with_content(/Short-Description: Start up JIRA/) } + .with_content(/Short-Description: Start up JIRA/) + .with_content(/lockfile=\/var\/lock\/subsys\/jira/) + } + it { should_not contain_file('/usr/lib/systemd/system/jira.service') + .with_content(/Atlassian Systemd Jira Service/) } + it { should_not contain_exec('refresh_systemd') } + end + context 'lockfile on Debian' do + let(:params) {{ + :javahome => '/opt/java', + }} + let(:facts) {{ + :osfamily => 'Debian', + }} + it { should contain_file('/etc/init.d/jira') + .with_content(/\/var\/lock\/jira/) } end context 'overwriting service_manage param' do let(:params) {{ :service_manage => false, - :javahome => '/opt/java', + :javahome => '/opt/java', }} it { should_not contain_service('jira')} end context 'overwriting service_manage param with bad boolean' do let(:params) {{ :service_manage => 'false', - :javahome => '/opt/java', + :javahome => '/opt/java', }} it do expect { @@ -30,7 +45,7 @@ end context 'overwriting service params' do let(:params) {{ - :javahome => '/opt/java', + :javahome => '/opt/java', :service_ensure => 'stopped', :service_enable => false, }} @@ -49,6 +64,7 @@ }} it { should contain_file('/usr/lib/systemd/system/jira.service') .with_content(/Atlassian Systemd Jira Service/) } + it { should contain_exec('refresh_systemd') } end end From 0ba92b7b5d06225dc7b6fffa790eb2a031673718 Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Sat, 17 Jan 2015 15:36:57 +0200 Subject: [PATCH 03/13] Add tests for MySQL * Add tests for param dburl * Add tests for MySQL java connector * Update CHANGELOG * correct spacing in /manifests/facts.pp --- CHANGELOG.md | 8 +++++ manifests/facts.pp | 6 ++-- spec/classes/jira_config_spec.rb | 50 +++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d6454da..1826bd37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +##2014-11-18 - Release 1.1.4 +- Parameterize the lockfile variable in the init script +- Autoinstall MySql Connector/J Driver +- Add parameter stop_jira +- Fix bug on RHEL7 where updating the systemd script does not take effect without refreshing systemd + +Thanks to MasonM for his contributions + ##2014-11-17 - Release 1.1.3 - Refactor beaker tests to that they are portable and other people can run them - Remove unnecessary comments from init.pp diff --git a/manifests/facts.pp b/manifests/facts.pp index 0e9ab7ac..a94d65e6 100644 --- a/manifests/facts.pp +++ b/manifests/facts.pp @@ -15,9 +15,9 @@ # class { 'jira::facts': } # class jira::facts( - $ensure = 'present', - $port = $jira::tomcatPort, - $uri = '127.0.0.1', + $ensure = 'present', + $port = $jira::tomcatPort, + $uri = '127.0.0.1', $json_packages = $jira::params::json_packages, ) inherits jira::params { diff --git a/spec/classes/jira_config_spec.rb b/spec/classes/jira_config_spec.rb index 017b96e8..d1328df6 100644 --- a/spec/classes/jira_config_spec.rb +++ b/spec/classes/jira_config_spec.rb @@ -10,7 +10,55 @@ it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/bin/setenv.sh')} it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/bin/user.sh')} it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/conf/server.xml')} - it { should contain_file('/home/jira/dbconfig.xml')} + it { should contain_file('/home/jira/dbconfig.xml') + .with_content(/jdbc:postgresql:\/\/localhost:5432\/jira<\/url>/) } + end + context 'mysql params' do + let(:params) {{ + :version => '6.3.4a', + :javahome => '/opt/java', + :db => 'mysql', + }} + it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/bin/setenv.sh')} + it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/bin/user.sh')} + it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/conf/server.xml')} + it { should contain_file('/home/jira/dbconfig.xml') + .with_content(/jdbc:mysql:\/\/localhost:5432\/jira\?useUnicode=true&characterEncoding=UTF8&sessionVariables=storage_engine=InnoDB<\/url>/) } + it { should contain_package('mysql-connector-java').with_ensure('installed')} + it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/lib/mysql-connector-java.jar') + .with( + 'ensure' => 'link', + 'target' => '/usr/share/java/mysql-connector-java.jar', + ) + } + end + context 'mysql params on Debian' do + let(:facts) { { + :osfamily => 'Debian', + }} + let(:params) {{ + :version => '6.3.4a', + :javahome => '/opt/java', + :db => 'mysql', + }} + it { should contain_package('libmysql-java').with_ensure('installed')} + it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/lib/mysql-connector-java.jar') + .with( + 'ensure' => 'link', + 'target' => '/usr/share/java/mysql.jar', + ) + } + end + context 'custom dburl' do + let(:params) {{ + :version => '6.3.4a', + :javahome => '/opt/java', + :dburl => 'my custom dburl', + }} + it { should contain_file('/home/jira/dbconfig.xml') + .with_content(/my custom dburl<\/url>/) } + end + end end From ad73ac228c6d21390e0807a77047e4cdc7f0e954 Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Sat, 17 Jan 2015 15:47:25 +0200 Subject: [PATCH 04/13] bump version, fix license name --- metadata.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metadata.json b/metadata.json index f8b6b525..f66dee54 100644 --- a/metadata.json +++ b/metadata.json @@ -1,9 +1,9 @@ { "name": "mkrakowitzer-jira", - "version": "1.1.3", + "version": "1.1.4", "author": "brycejohnson", "summary": "Module to install Jira", - "license": "Apache License, Version 2.0", + "license": "Apache-2.0", "source": "https://github.com/brycejohnson/puppet-jira.git", "project_page": "https://github.com/brycejohnson/puppet-jira/blob/master/README.md", "issues_url": "https://github.com/brycejohnson/puppet-jira/issues", @@ -25,7 +25,7 @@ "requirements": [ { "name": "pe", - "version_requirement": "3.x" + "version_requirement": ">=3.0.0 <4.0.0" }, { "name": "puppet", From 5c3e0a0052a45d8bf68d5ff743288b745cbc4c55 Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Sat, 17 Jan 2015 19:39:09 +0200 Subject: [PATCH 05/13] Move Exec defaults to params.pp so it is inherited by other classes --- manifests/init.pp | 2 -- manifests/params.pp | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 7f8e6e2e..298dfb17 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -107,8 +107,6 @@ ) inherits jira::params { - Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ] } - if $jira::db != 'postgresql' and $jira::db != 'mysql' { fail('jira db parameter must be postgresql or mysql') } diff --git a/manifests/params.pp b/manifests/params.pp index ed6069cc..bd3d1c7d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -3,6 +3,9 @@ # Defines default values for jira module # class jira::params { + + Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ] } + case "${::osfamily}${::operatingsystemmajrelease}" { /RedHat7/: { $json_packages = 'rubygem-json' From 0d717205ef3801bc166886ccd3779bc615b5edca Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Sat, 17 Jan 2015 20:28:53 +0200 Subject: [PATCH 06/13] Prep for 1.1.5 jira release --- CHANGELOG.md | 7 ++++++- README.md | 7 +++++-- metadata.json | 16 +++++++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1826bd37..8cfd6a4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ -##2014-11-18 - Release 1.1.4 +##2014-XX-XX - Release 1.1.5 +- TODO - Add beaker tests for MySQL +- Added support for Oracle and Scientific Linux +- Validate all parameters + +##2014-01-17 - Release 1.1.4 - Parameterize the lockfile variable in the init script - Autoinstall MySql Connector/J Driver - Add parameter stop_jira diff --git a/README.md b/README.md index 7d247393..d14ccc88 100644 --- a/README.md +++ b/README.md @@ -387,8 +387,11 @@ Enable external facts for puppet version. These facts are required to be enabled The puppetlabs repositories can be found at: http://yum.puppetlabs.com/ and http://apt.puppetlabs.com/ -* RedHat / CentOS 5/6/7 -* Ubuntu 12.04 / 14.04 +* RedHat 6/7 +* CentOS 6/7 +* Scientific 6/7 +* OracleLinux 6/7 +* Ubuntu 12.04/14.04 * Debian 7 We plan to support other Linux distributions and possibly Windows in the near future. diff --git a/metadata.json b/metadata.json index f66dee54..39ecd003 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "mkrakowitzer-jira", - "version": "1.1.4", + "version": "1.1.5", "author": "brycejohnson", "summary": "Module to install Jira", "license": "Apache-2.0", @@ -47,6 +47,20 @@ "7" ] }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "6", + "7" + ] + }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ From ff353688fe7c513277b7f9930d54c915a31aa6ff Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Sat, 17 Jan 2015 20:38:41 +0200 Subject: [PATCH 07/13] Bump jira version to 6.3.13 --- CHANGELOG.md | 1 + manifests/init.pp | 2 +- spec/classes/jira_upgrade_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cfd6a4a..6b10918a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - TODO - Add beaker tests for MySQL - Added support for Oracle and Scientific Linux - Validate all parameters +- Bump jira version to 6.3.13 ##2014-01-17 - Release 1.1.4 - Parameterize the lockfile variable in the init script diff --git a/manifests/init.pp b/manifests/init.pp index 298dfb17..013b9efb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -33,7 +33,7 @@ class jira ( # Jira Settings - $version = '6.3.4a', + $version = '6.3.13', $product = 'jira', $format = 'tar.gz', $installdir = '/opt/jira', diff --git a/spec/classes/jira_upgrade_spec.rb b/spec/classes/jira_upgrade_spec.rb index 4d946903..d4892324 100644 --- a/spec/classes/jira_upgrade_spec.rb +++ b/spec/classes/jira_upgrade_spec.rb @@ -7,7 +7,7 @@ :javahome => '/opt/java', }} let(:facts) { { - :jira_version => "5.0.0", + :jira_version => '6.3.4a', }} it { should contain_exec('service jira stop && sleep 15') } end @@ -17,7 +17,7 @@ :stop_jira => 'stop service please' }} let(:facts) { { - :jira_version => "5.0.0", + :jira_version => '6.3.4a', }} it { should contain_exec('stop service please') } end From dbc279a7f40c2c587a82a3f805badb27b117bf4f Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Sun, 18 Jan 2015 20:13:37 +0200 Subject: [PATCH 08/13] For consistency we should use the dbtype paramater for dbconfig.mysql.xml.erb --- templates/dbconfig.mysql.xml.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/dbconfig.mysql.xml.erb b/templates/dbconfig.mysql.xml.erb index d4cdbebb..b06ba9fb 100644 --- a/templates/dbconfig.mysql.xml.erb +++ b/templates/dbconfig.mysql.xml.erb @@ -3,7 +3,7 @@ defaultDS default - mysql + <%= scope.lookupvar('jira::dbtype') %> <%= scope.lookupvar('jira::dburl_real') %> <%= scope.lookupvar('jira::dbdriver') %> From 451d1159032e28d54986858f3f67a52455ce637c Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Mon, 19 Jan 2015 07:12:13 +0200 Subject: [PATCH 09/13] Manage the installation of the Mysql Java Connector with jira module Resolve issue #45 This particular issue [1] happens in both Ubuntu 12.04 and RHEL/Centos 6 by default when using the na [1] https://confluence.atlassian.com/display/JIRAKB/%27NullPointerException+at+com.mysql.jdbc.Connect [2] https://confluence.atlassian.com/display/JIRA/Connecting+JIRA+to+MySQL [3] http://dev.mysql.com/downloads/connector/j --- README.md | 42 +++++--- manifests/init.pp | 11 ++- manifests/install.pp | 17 ++-- manifests/mysql_connector.pp | 38 +++++++ manifests/params.pp | 6 -- spec/acceptance/default_parameters_spec.rb | 38 +++---- spec/acceptance/mysql_spec.rb | 110 +++++++++++++++++++++ spec/classes/jira_config_spec.rb | 26 ----- spec/classes/jira_install_deploy_spec.rb | 4 + spec/classes/jira_mysql_connector_spec.rb | 67 +++++++++++++ spec/spec_helper_acceptance.rb | 3 +- 11 files changed, 281 insertions(+), 81 deletions(-) create mode 100644 manifests/mysql_connector.pp create mode 100644 spec/acceptance/mysql_spec.rb create mode 100644 spec/classes/jira_mysql_connector_spec.rb diff --git a/README.md b/README.md index d14ccc88..a071951a 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ Specifies the version of JIRA to install, defaults to latest available at time o #####`$product` -Product name, defaults to JIRA +Product name, defaults to jira #####`$format` @@ -147,7 +147,7 @@ The gid of the JIRA user, defaults to next available (undef) #####`$db` -Which database to use for JIRA, defaults to 'postgresql' +Which database to use for JIRA, defaults to 'postgresql'. Can be 'postgresql' or 'mysql'. #####`$dbuser` @@ -163,31 +163,26 @@ The hostname of the database server, defaults to 'localhost' #####`$dbname` -The name of the database, defaults to 'jira' +The name of the database, defaults to 'jira'. If using oracle this should be the SID. #####`$dbport` -The port of the database, defaults to '5432' +The port of the database, defaults to '5432'. MySQL runs on '3306'. #####`$dbdriver` -The database driver to use, defaults to 'org.postgresql.Driver' +The database driver to use, defaults to 'org.postgresql.Driver'. Can be 'org.postgresql.Driver', 'com.mysql.jdbc.Driver' or 'oracle.jdbc.OracleDriver'. #####`$dbtype` -Database type, defaults to 'postgres72' +Database type, defaults to 'postgres72'. Can be 'postgres72', 'mysql' or 'oracle10g'. #####`$poolsize` The connection pool size to the database, defaults to 20 -#####`$mysql_connector_package` - -Package name for the MySQL Connector/J driver. Will be automatically installed if set and $dbtype = 'mysql'. Defaults to 'mysql-connector-java' on Redhat and 'libmysql-java' on Debian. - -#####`$mysql_connector_jar` - -Path to the JAR for the MySQL Connector/J driver. Defaults to '/usr/share/java/mysql-connector-java.jar' on Redhat and '/usr/share/java/mysql.jar' on Debian. +#####`$dburl` +This parameter is not required nor do we recomend setting it. However it can be used to customize the database connection string. #####`$enable_connection_pooling` @@ -237,6 +232,27 @@ defaults to true defaults to true +####MySQL Java Connector parameters#### + +#####`mysql_connector_manage` +Manage the MySQL Java Connector with the JIRA module, defaults to 'true' + +#####`mysql_connector_version` +Specifies the version of MySQL Java Connector you would like installed. Defaults to '5.1.34', + +#####`$mysql_connector_product` +Product name, defaults to 'mysql-connector-java' + +#####`$mysql_connector_format` +The default file format of the MySQL Java Connector install file, defaults to tar.gz + +#####`$mysql_connector_install` +Installation directory of the MySQL connector. Defaults to '/opt/MySQL-connector' + +#####`$mysql_connector_URL` +The URL used to download the MySQL Java Connector installation file. +Defaults to 'http://cdn.mysql.com/Downloads/Connector-J' + ####JVM Java parameters#### #####`$javahome` diff --git a/manifests/init.pp b/manifests/init.pp index 013b9efb..688da99c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -54,8 +54,15 @@ $dbtype = 'postgres72', $dburl = undef, $poolsize = '20', - $mysql_connector_package = $jira::params::mysql_connector_package, - $mysql_connector_jar = $jira::params::mysql_connector_jar, + + # MySQL Connector Settings + $mysql_connector_manage = true, + $mysql_connector_version = '5.1.34', + $mysql_connector_product = 'mysql-connector-java', + $mysql_connector_format = 'tar.gz', + $mysql_connector_install = '/opt/MySQL-connector', + $mysql_connector_URL = 'http://cdn.mysql.com/Downloads/Connector-J', + # Configure database settings if you are pooling connections $enable_connection_pooling = false, diff --git a/manifests/install.pp b/manifests/install.pp index db326187..ee01f3c4 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -101,14 +101,15 @@ subscribe => User[$jira::user] } - if $jira::db == 'mysql' and $jira::mysql_connector_package { - package { $jira::mysql_connector_package: - ensure => installed, - } -> - - file { "${jira::webappdir}/lib/mysql-connector-java.jar": - ensure => link, - target => $jira::mysql_connector_jar, + if $jira::db == 'mysql' and $jira::mysql_connector_manage { + if $jira::staging_or_deploy == 'staging' { + class { 'jira::mysql_connector': + require => Staging::Extract[$file], + } + } elsif $jira::staging_or_deploy == 'deploy' { + class { 'jira::mysql_connector': + require => Deploy::File[$file], + } } } } diff --git a/manifests/mysql_connector.pp b/manifests/mysql_connector.pp new file mode 100644 index 00000000..53469224 --- /dev/null +++ b/manifests/mysql_connector.pp @@ -0,0 +1,38 @@ +# Class to install the MySQL Java connector +class jira::mysql_connector ( + $version = $jira::mysql_connector_version, + $product = $jira::mysql_connector_product, + $format = $jira::mysql_connector_format, + $installdir = $jira::mysql_connector_install, + $downloadURL = $jira::mysql_connector_URL, +) { + + require staging + + $file = "${product}-${version}.${format}" + + if ! defined(File[$installdir]) { + file { $installdir: + ensure => 'directory', + owner => root, + group => root, + before => Staging::File[$file] + } + } + + staging::file { $file: + source => "${downloadURL}/${file}", + timeout => 300, + } -> + + staging::extract { $file: + target => $installdir, + creates => "${installdir}/${product}-${version}", + } -> + + file { "${jira::webappdir}/lib/mysql-connector-java.jar": + ensure => link, + target => "${installdir}/${product}-${version}/${product}-${version}-bin.jar", + } + +} diff --git a/manifests/params.pp b/manifests/params.pp index bd3d1c7d..56d47be1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,24 +9,18 @@ case "${::osfamily}${::operatingsystemmajrelease}" { /RedHat7/: { $json_packages = 'rubygem-json' - $mysql_connector_package = 'mysql-connector-java' - $mysql_connector_jar = '/usr/share/java/mysql-connector-java.jar' $service_file_location = '/usr/lib/systemd/system/jira.service' $service_file_template = 'jira/jira.service.erb' $service_lockfile = '/var/lock/subsys/jira' } /Debian/: { $json_packages = [ 'rubygem-json', 'ruby-json' ] - $mysql_connector_package = 'libmysql-java' - $mysql_connector_jar = '/usr/share/java/mysql.jar' $service_file_location = '/etc/init.d/jira' $service_file_template = 'jira/jira.initscript.erb' $service_lockfile = '/var/lock/jira' } default: { $json_packages = [ 'rubygem-json', 'ruby-json' ] - $mysql_connector_package = 'mysql-connector-java' - $mysql_connector_jar = '/usr/share/java/mysql-connector-java.jar' $service_file_location = '/etc/init.d/jira' $service_file_template = 'jira/jira.initscript.erb' $service_lockfile = '/var/lock/subsys/jira' diff --git a/spec/acceptance/default_parameters_spec.rb b/spec/acceptance/default_parameters_spec.rb index 17f1c051..e50b55da 100644 --- a/spec/acceptance/default_parameters_spec.rb +++ b/spec/acceptance/default_parameters_spec.rb @@ -15,7 +15,7 @@ java_url = download_url end -describe 'jira', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do +describe 'jira postgresql', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do it 'installs with defaults' do pp = <<-EOS @@ -59,29 +59,6 @@ class { 'jira::facts': } apply_manifest(pp, :catch_changes => true) end -# Need to insert license key before upgrade -# it 'upgrades with defaults' do -# pp_update = <<-EOS -# $jh = $osfamily ? { -# 'RedHat' => '/usr/lib/jvm/java-1.7.0-openjdk.x86_64', -# 'Debian' => '/usr/lib/jvm/java-7-openjdk-amd64', -# default => '/opt/java', -# } -# class { 'stash': -# version => '3.3.1', -# downloadURL => 'http://10.43.230.24/', -# javahome => $jh, -# } -# EOS -# sleep 180 -# shell 'wget -q --tries=180 --retry-connrefused --read-timeout=10 localhost:8080', :acceptable_exit_codes => [0] -# apply_manifest(pp_update, :catch_failures => true) -# shell 'wget -q --tries=180 --retry-connrefused --read-timeout=10 localhost:8080', :acceptable_exit_codes => [0] -# sleep 180 -# shell 'wget -q --tries=180 --retry-connrefused --read-timeout=10 localhost:8080', :acceptable_exit_codes => [0] -# apply_manifest(pp_update, :catch_changes => true) -# end -# describe process("java") do it { should be_running } end @@ -92,6 +69,7 @@ class { 'jira::facts': } describe service('jira') do it { should be_enabled } + it { should be_running } end describe user('jira') do @@ -106,4 +84,16 @@ class { 'jira::facts': } it { should have_login_shell '/bin/true' } end + describe command('wget -q --tries=240 --retry-connrefused --read-timeout=10 -O- localhost:8080') do + its(:stdout) { should match /6\.2\.7/ } + end + + describe 'shutdown' do + it { shell("service jira stop", :acceptable_exit_codes => [0,1]) } + it { shell("pkill -f postgres", :acceptable_exit_codes => [0,1]) } + it { shell("pkill -f postgres", :acceptable_exit_codes => [0,1]) } + it { shell("pkill -f jira", :acceptable_exit_codes => [0,1]) } + it { shell("pkill -f jira", :acceptable_exit_codes => [0,1]) } + end + end diff --git a/spec/acceptance/mysql_spec.rb b/spec/acceptance/mysql_spec.rb new file mode 100644 index 00000000..03a94d8a --- /dev/null +++ b/spec/acceptance/mysql_spec.rb @@ -0,0 +1,110 @@ +require 'spec_helper_acceptance' + +# It is sometimes faster to host jira / java files on a local webserver. +# Set environment variable download_url to use local webserver +# export download_url = 'http://10.0.0.XXX/' +download_url = ENV['download_url'] if ENV['download_url'] +if ENV['download_url'] then + download_url = ENV['download_url'] +else + download_url = 'undef' +end +if download_url == 'undef' then + java_url = "'http://download.oracle.com/otn-pub/java/jdk/7u71-b14/'" +else + java_url = download_url +end + +describe 'jira mysql', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + it 'installs with mysql database' do + pp = <<-EOS + $jh = $osfamily ? { + default => '/opt/java', + } + if versioncmp($::puppetversion,'3.6.1') >= 0 { + $allow_virtual_packages = hiera('allow_virtual_packages',false) + Package { + allow_virtual => $allow_virtual_packages, + } + } + class { '::mysql::server': + root_password => 'strongpassword', + } -> + class { 'mysql::bindings': + java_enable => true, + } -> + mysql::db { 'jira': + user => 'jiraadm', + password => 'mypassword', + host => 'localhost', + grant => ['ALL'], + }-> + deploy::file { 'jdk-7u71-linux-x64.tar.gz': + target => $jh, + fetch_options => '-q -c --header "Cookie: oraclelicense=accept-securebackup-cookie"', + url => #{java_url}, + download_timout => 1800, + strip => true, + } -> + class { 'jira': + installdir => '/opt/atlassian-jira', + homedir => '/opt/jira-home', + version => '6.3.6', + downloadURL => #{download_url}, + javahome => $jh, + db => 'mysql', + dbport => '3306', + dbdriver => 'com.mysql.jdbc.Driver', + dbtype => 'mysql', + tomcatPort => '8081', + } + class { 'jira::facts': } + EOS + apply_manifest(pp, :catch_failures => true) + sleep 60 + shell 'wget -q --tries=240 --retry-connrefused --read-timeout=10 localhost:8081', :acceptable_exit_codes => [0,8] + sleep 60 + shell 'wget -q --tries=240 --retry-connrefused --read-timeout=10 localhost:8081', :acceptable_exit_codes => [0,8] + sleep 60 + apply_manifest(pp, :catch_changes => true) + end + + describe process("java") do + it { should be_running } + end + + describe port(8081) do + it { is_expected.to be_listening } + end + + describe service('jira') do + it { should be_enabled } + it { should be_running } + end + + describe user('jira') do + it { should exist } + end + + describe user('jira') do + it { should belong_to_group 'jira' } + end + + describe user('jira') do + it { should have_login_shell '/bin/true' } + end + + describe command('wget -q --tries=240 --retry-connrefused --read-timeout=10 -O- localhost:8081') do + its(:stdout) { should match /6\.3\.6/ } + end + + describe 'shutdown' do + it { shell("service jira stop", :acceptable_exit_codes => [0,1]) } + it { shell("pkill -f mysql", :acceptable_exit_codes => [0,1]) } + it { shell("pkill -f mysql", :acceptable_exit_codes => [0,1]) } + it { shell("pkill -f jira", :acceptable_exit_codes => [0,1]) } + it { shell("pkill -f jira", :acceptable_exit_codes => [0,1]) } + end + +end diff --git a/spec/classes/jira_config_spec.rb b/spec/classes/jira_config_spec.rb index d1328df6..d54ee606 100644 --- a/spec/classes/jira_config_spec.rb +++ b/spec/classes/jira_config_spec.rb @@ -12,7 +12,6 @@ it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/conf/server.xml')} it { should contain_file('/home/jira/dbconfig.xml') .with_content(/jdbc:postgresql:\/\/localhost:5432\/jira<\/url>/) } - end context 'mysql params' do let(:params) {{ @@ -25,30 +24,6 @@ it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/conf/server.xml')} it { should contain_file('/home/jira/dbconfig.xml') .with_content(/jdbc:mysql:\/\/localhost:5432\/jira\?useUnicode=true&characterEncoding=UTF8&sessionVariables=storage_engine=InnoDB<\/url>/) } - it { should contain_package('mysql-connector-java').with_ensure('installed')} - it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/lib/mysql-connector-java.jar') - .with( - 'ensure' => 'link', - 'target' => '/usr/share/java/mysql-connector-java.jar', - ) - } - end - context 'mysql params on Debian' do - let(:facts) { { - :osfamily => 'Debian', - }} - let(:params) {{ - :version => '6.3.4a', - :javahome => '/opt/java', - :db => 'mysql', - }} - it { should contain_package('libmysql-java').with_ensure('installed')} - it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/lib/mysql-connector-java.jar') - .with( - 'ensure' => 'link', - 'target' => '/usr/share/java/mysql.jar', - ) - } end context 'custom dburl' do let(:params) {{ @@ -59,6 +34,5 @@ it { should contain_file('/home/jira/dbconfig.xml') .with_content(/my custom dburl<\/url>/) } end - end end diff --git a/spec/classes/jira_install_deploy_spec.rb b/spec/classes/jira_install_deploy_spec.rb index f6730e54..784d38f1 100644 --- a/spec/classes/jira_install_deploy_spec.rb +++ b/spec/classes/jira_install_deploy_spec.rb @@ -27,6 +27,7 @@ 'group' => 'jira' }) end + it { should_not contain_class('jira::mysql_connector')} end context 'overwriting params' do @@ -67,6 +68,9 @@ 'group' => 'bar' }) end + + it { should_not contain_class('jira::mysql_connector')} end + end end diff --git a/spec/classes/jira_mysql_connector_spec.rb b/spec/classes/jira_mysql_connector_spec.rb new file mode 100644 index 00000000..c3b4019c --- /dev/null +++ b/spec/classes/jira_mysql_connector_spec.rb @@ -0,0 +1,67 @@ +require 'spec_helper.rb' + +describe 'jira' do + describe 'jira::mysql_connector' do + context 'mysql connector defaults' do + let(:params) {{ + :version => '6.3.4a', + :javahome => '/opt/java', + :db => 'mysql', + :mysql_connector_version => '5.1.34', + }} + it { should contain_file('/opt/MySQL-connector').with_ensure('directory')} + it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/lib/mysql-connector-java.jar') + .with( + 'ensure' => 'link', + 'target' => '/opt/MySQL-connector/mysql-connector-java-5.1.34/mysql-connector-java-5.1.34-bin.jar', + ) + } + it 'should deploy mysql connector 5.1.34 from tar.gz' do + should contain_staging__file("mysql-connector-java-5.1.34.tar.gz").with({ + 'source' => 'http://cdn.mysql.com/Downloads/Connector-J/mysql-connector-java-5.1.34.tar.gz', + }) + should contain_staging__extract("mysql-connector-java-5.1.34.tar.gz").with({ + 'target' => '/opt/MySQL-connector', + 'creates' => '/opt/MySQL-connector/mysql-connector-java-5.1.34', + }) + end + end + context 'mysql connector overwrite params' do + let(:params) {{ + :version => '6.3.4a', + :javahome => '/opt/java', + :db => 'mysql', + :mysql_connector_version => '5.1.15', + :mysql_connector_format => 'zip', + :mysql_connector_install => '/opt/foo', + :mysql_connector_URL => 'http://example.co.za/foo', + + }} + it { should contain_file('/opt/foo').with_ensure('directory')} + it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/lib/mysql-connector-java.jar') + .with( + 'ensure' => 'link', + 'target' => '/opt/foo/mysql-connector-java-5.1.15/mysql-connector-java-5.1.15-bin.jar', + ) + } + it 'should deploy mysql connector 5.1.15 from zip' do + should contain_staging__file("mysql-connector-java-5.1.15.zip").with({ + 'source' => 'http://example.co.za/foo/mysql-connector-java-5.1.15.zip', + }) + should contain_staging__extract("mysql-connector-java-5.1.15.zip").with({ + 'target' => '/opt/foo', + 'creates' => '/opt/foo/mysql-connector-java-5.1.15', + }) + end + end + context 'mysql_connector_mangage equals false' do + let(:params) {{ + :version => '6.3.4a', + :javahome => '/opt/java', + :db => 'mysql', + :mysql_connector_manage => false, + }} + it { should_not contain_class('jira::mysql_connector')} + end + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 5bc7db00..a5a78452 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -39,9 +39,8 @@ end on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } on host, puppet('module','install','puppetlabs-postgresql'), { :acceptable_exit_codes => [0,1] } - on host, puppet('module','install','yguenane-repoforge'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','puppetlabs-mysql'), { :acceptable_exit_codes => [0,1] } on host, puppet('module','install','mkrakowitzer-deploy'), { :acceptable_exit_codes => [0,1] } - on host, puppet('module','install','puppetlabs-java'), { :acceptable_exit_codes => [0,1] } on host, puppet('module','install','nanliu-staging'), { :acceptable_exit_codes => [0,1] } end end From b0fcde9a402f244f29d9bfbea58c9d2e1081757f Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Mon, 19 Jan 2015 09:23:43 +0100 Subject: [PATCH 10/13] Add path attribute in server.xml.erb. This adds the template parameter and the necessary parameter to init.pp. It adds validations for $contextpath, $proxy and $db, too. --- README.md | 5 +++++ jira.yaml | 2 ++ manifests/init.pp | 9 ++++++--- templates/server.xml.erb | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7d247393..62c2a281 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,10 @@ If the jira service is managed outside of puppet the stop_jira paramater can be Defaults to {}, See examples on how to use. +#####`$contextpath = ""` + +Defaults to an empty string (""). Will add a path to the Tomcat Server Context. + ####Tomcat parameters#### #####`$tomcatPort` @@ -363,6 +367,7 @@ jira::proxy: scheme: 'https' proxyName: 'jira.example.co.za' proxyPort: '443' +jira::contextpath: '/jira' ``` Reverse proxy can be configured as a hash as part of the JIRA resource diff --git a/jira.yaml b/jira.yaml index 0a3ddf21..82746c01 100644 --- a/jira.yaml +++ b/jira.yaml @@ -100,3 +100,5 @@ jira::proxy: scheme: 'https' proxyName: 'www.exmaple.co.za' proxyPort: '443' +# Configure path attribute for the +jira::contextpath: '/jira' diff --git a/manifests/init.pp b/manifests/init.pp index 298dfb17..f1562d54 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -104,12 +104,15 @@ # Reverse https proxy $proxy = {}, + # Context path (usualy used in combination with a reverse proxy) + $contextpath = '', ) inherits jira::params { - if $jira::db != 'postgresql' and $jira::db != 'mysql' { - fail('jira db parameter must be postgresql or mysql') - } + # Parameter validations + validate_re($db, ['^postgresql','^mysql'], 'The JIRA $db parameter must be "postgresql" or "mysql".') + validate_hash($proxy) + validate_re($contextpath, ['^$', '^/.*']) if $::jira_version { # If the running version of JIRA is less than the expected version of JIRA diff --git a/templates/server.xml.erb b/templates/server.xml.erb index def0b4ca..d6e2511f 100644 --- a/templates/server.xml.erb +++ b/templates/server.xml.erb @@ -119,7 +119,7 @@ - +