diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d6454da..8596b628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +##2014-01-21 - Release 1.1.5 +- Add beaker tests for MySQL +- Added support for Oracle and Scientific Linux +- Bump jira version to 6.3.13 +- Add support for parameter 'contextpath' +- Add class to install MySQL Java connector from mysql.com +- Add support for oracle database + +Thanks to Oliver Bertuch for his contributions. + +##2014-01-17 - 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/README.md b/README.md index 8800ff1e..a7ec8470 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ This module installs/upgrades Atlassian's Enterprise Issue Tracking and project ###JIRA Prerequisites -* JIRA requires a Java Developers Kit (JDK) or Java Run-time Environment (JRE) platform to be installed on your server's operating system. Oracle JDK / JRE (formerly Sun JDK / JRE) versions 7 and 8 are currently supported by Atlassian. +* JIRA requires a Java Developers Kit (JDK) or Java Run-time Environment (JRE) platform to be installed on your server's operating system. Oracle JDK / JRE (formerly Sun JDK / JRE) versions 7 and 8 are currently supported by Atlassian. -* JIRA requires a relational database to store its issue data. This module currently supports PostgreSQL 8.4 to 9.x and MySQL 5.x. We suggest using puppetlabs-postgresql/puppetlabs-mysql modules to configure/manage the database. The module uses PostgreSQL as a default. +* JIRA requires a relational database to store its issue data. This module currently supports PostgreSQL 8.4 to 9.x and MySQL 5.x and Oracle 11g. We suggest using puppetlabs-postgresql/puppetlabs-mysql modules to configure/manage the database. The module uses PostgreSQL as a default. * Whilst not required, for production use we recommend using nginx/apache as a reverse proxy to JIRA. We suggest using the jfryman/nginx puppet module. @@ -42,10 +42,12 @@ This module installs/upgrades Atlassian's Enterprise Issue Tracking and project If installing to an existing JIRA instance, it is your responsibility to backup your database. We also recommend that you backup your JIRA home directory and that you align your current JIRA version with the version you intend to use with puppet JIRA module. -You must have your database setup with the account user that JIRA will use. This can be done using the puppetlabs-postgresql and puppetlabs-mysql modules. +You must have your database setup with the account user that JIRA will use. This can be done using the puppetlabs-postgresql and puppetlabs-mysql modules. When using this module to upgrade JIRA, please make sure you have a database/JIRA home backup. +When using MySQL, We call the jira::mysql_connector class to install the MySQL java connector directory from mysql.com as per Atlassian's documented recommendations. + ###Beginning with JIRA @@ -102,6 +104,7 @@ mkrakowitzer-deploy has been replaced with nanliu-staging as the default module * `jira::install`: Installs JIRA binaries * `jira::config`: Modifies jira/tomcat configuration files * `jira::service`: Manage the JIRA service. +* `jira::mysql_connector`: Install/Manage the MySQL Java connector ###Parameters @@ -113,7 +116,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 +150,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', 'mysql' or 'oracle'. #####`$dbuser` @@ -163,31 +166,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'. Oracle runs on '1521'. #####`$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'. Atlassian only supports Oracle 11g, even so this value should be as documented here. #####`$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 recommend setting it. However it can be used to customize the database connection string. #####`$enable_connection_pooling` @@ -237,6 +235,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` @@ -291,10 +310,17 @@ Manage the JIRA service, defaults to 'running' Defaults to 'true' +#####`$stop_jira` +If the jira service is managed outside of puppet the stop_jira parameter 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. +#####`$contextpath = ""` + +Defaults to an empty string (""). Will add a path to the Tomcat Server Context. + ####Tomcat parameters#### #####`$tomcatPort` @@ -328,7 +354,7 @@ Defaults to '100' ### A Hiera example -This example is used in production for 2000 users in an traditional enterprise environment. Your milage may vary. The dbpassword can be stored using eyaml hiera extension. +This example is used in production for 2000 users in an traditional enterprise environment. Your mileage may vary. The dbpassword can be stored using eyaml hiera extension. ```yaml jira::version: '6.2.7' @@ -360,6 +386,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 @@ -384,10 +411,17 @@ 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 +* Oracle Linux 6/7 +* Ubuntu 12.04/14.04 * Debian 7 +* PostgreSQL +* MySQL 5.x +* Oracle 11G with Oracle 11.2.x drivers + We plan to support other Linux distributions and possibly Windows in the near future. ##Development @@ -425,7 +459,7 @@ BEAKER_set=centos-70-x64 bundle exec rake beaker BEAKER_set=centos-64-x64-pe bundle exec rake beaker ``` -To save build time it is useful to host the installation files locally on a webserver. You can use the download_url environment variable to overwrite the default. +To save build time it is useful to host the installation files locally on a web server. You can use the download_url environment variable to overwrite the default. ```bash export download_url="'http://my.local.server/'" diff --git a/jira.yaml b/jira.yaml index ea2668bf..ee9990be 100644 --- a/jira.yaml +++ b/jira.yaml @@ -104,3 +104,5 @@ jira::proxy: scheme: 'https' proxyName: 'www.exmaple.co.za' proxyPort: '443' +# Configure path attribute for the +jira::contextpath: '/jira' diff --git a/manifests/config.pp b/manifests/config.pp index e0f2a704..ad9e79b4 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -24,6 +24,7 @@ $validationQuery = $jira::db ? { 'postgresql' => 'select version();', 'mysql' => 'select 1', + 'oracle' => 'select 1 from dual', 'sqlserver' => 'select 1', } } @@ -31,6 +32,7 @@ $timeBetweenEvictionRuns = $jira::db ? { 'postgresql' => '30000', 'mysql' => '300000', + 'oracle' => '300000', 'sqlserver' => '300000', } } 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/manifests/init.pp b/manifests/init.pp index 2db7123e..2df888f8 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', @@ -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, @@ -90,6 +97,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, @@ -100,21 +111,22 @@ # Reverse https proxy $proxy = {}, + # Context path (usualy used in combination with a reverse proxy) + $contextpath = '', ) inherits jira::params { - Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ] } - - if $jira::db != 'postgresql' and $jira::db != 'mysql' and $jira::db != 'sqlserver' { - fail('jira db parameter must be postgresql or mysql or sqlserver') - } + # Parameter validations + validate_re($db, ['^postgresql','^mysql','^sqlserver'], 'The JIRA $db parameter must be "postgresql", "mysql", "sqlserver".') + validate_hash($proxy) + validate_re($contextpath, ['^$', '^/.*']) if $::jira_version { # If the running version of JIRA is less than the expected version of JIRA # 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'] } } } @@ -126,6 +138,7 @@ $dburl_real = $db ? { 'postgresql' => "jdbc:${db}://${dbserver}:${dbport}/${dbname}", 'mysql' => "jdbc:${db}://${dbserver}:${dbport}/${dbname}?useUnicode=true&characterEncoding=UTF8&sessionVariables=storage_engine=InnoDB", + 'oracle' => "jdbc::${db}:thin:@${dbserver}:${dbport}:${dbname}" 'sqlserver' => "jdbc:jtds:${db}://${dbserver}:${dbport}/${dbname}", } } 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 ed6069cc..56d47be1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -3,27 +3,24 @@ # 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' - $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/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/metadata.json b/metadata.json index f8b6b525..39ecd003 100644 --- a/metadata.json +++ b/metadata.json @@ -1,9 +1,9 @@ { "name": "mkrakowitzer-jira", - "version": "1.1.3", + "version": "1.1.5", "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", @@ -47,6 +47,20 @@ "7" ] }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "6", + "7" + ] + }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ 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 017b96e8..401085ba 100644 --- a/spec/classes/jira_config_spec.rb +++ b/spec/classes/jira_config_spec.rb @@ -10,7 +10,39 @@ 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>/) } + 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 + context 'tomcat context path' do + let(:params) {{ + :version => '6.3.4a', + :javahome => '/opt/java', + :contextpath => '/jira', + }} + it { should contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/conf/server.xml') + .with_content(//) } + 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/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 diff --git a/spec/classes/jira_upgrade_spec.rb b/spec/classes/jira_upgrade_spec.rb index 3f3bac2e..d4892324 100644 --- a/spec/classes/jira_upgrade_spec.rb +++ b/spec/classes/jira_upgrade_spec.rb @@ -7,9 +7,20 @@ :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 + context 'custom params' do + let(:params) {{ + :javahome => '/opt/java', + :stop_jira => 'stop service please' + }} + let(:facts) { { + :jira_version => '6.3.4a', + }} + it { should contain_exec('stop service please') } + 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 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') %> diff --git a/templates/dbconfig.oracle.xml.erb b/templates/dbconfig.oracle.xml.erb new file mode 100644 index 00000000..fb9f3574 --- /dev/null +++ b/templates/dbconfig.oracle.xml.erb @@ -0,0 +1,24 @@ + + + + defaultDS + default + <%= scope.lookupvar('jira::dbtype') %> + + <%= scope.lookupvar('jira::dburl_real') %> + <%= scope.lookupvar('jira::dbdriver') %> + <%= scope.lookupvar('jira::dbuser') %> + <%= scope.lookupvar('jira::dbpassword') %> + <%= scope.lookupvar('jira::poolMinSize') %> + <%= scope.lookupvar('jira::poolMaxSize') %> + <%= scope.lookupvar('jira::poolMaxWait') %> + <%= scope.lookupvar('jira::poolMaxIdle') %> + <%= scope.lookupvar('jira::poolRemoveAbandoned') %> + <%= scope.lookupvar('jira::poolRemoveAbandonedTimout') %> + <% if @validationQuery %><%= @validationQuery %><% else %>scope.lookupvar('jira::validationQuery')<% end %> + <%= scope.lookupvar('jira::minEvictableIdleTime') %> + <% if @timeBetweenEvictionRuns %><%= @timeBetweenEvictionRuns %><% else %><%= scope.lookupvar('jira::timeBetweenEvictionRuns') %><% end %> + <%= scope.lookupvar('jira::poolTestWhileIdle') %> + <%= scope.lookupvar('jira::poolTestOnBorrow') %> + + diff --git a/templates/server.xml.erb b/templates/server.xml.erb index def0b4ca..0a1d650e 100644 --- a/templates/server.xml.erb +++ b/templates/server.xml.erb @@ -119,7 +119,7 @@ - +