Skip to content

Commit

Permalink
Merge pull request #389 from dodevops/custom-plugin-installation
Browse files Browse the repository at this point in the history
  • Loading branch information
root-expert authored Nov 25, 2021
2 parents 6430b9e + 5dd2004 commit f2f8915
Show file tree
Hide file tree
Showing 16 changed files with 656 additions and 389 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
needs: setup_matrix
runs-on: ubuntu-latest
env:
LANG: en_US
LC_ALL: en_US.UTF-8
BUNDLE_WITHOUT: development:test:release
strategy:
fail-fast: false
Expand Down
3 changes: 3 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ Gemfile:
optional:
':test':
- gem: puppet-lint-param-docs
spec/spec_helper.rb:
spec_overrides:
- "require 'support/acceptance/constants.rb'"
16 changes: 10 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,21 @@
# Configuration logic ends, resources begin:

file { "${jira::webappdir}/bin/user.sh":
content => epp('jira/user.sh.epp'),
content => epp("${module_name}/user.sh.epp"),
mode => '0755',
}

file { "${jira::webappdir}/bin/setenv.sh":
content => epp('jira/setenv.sh.epp'),
content => epp("${module_name}/setenv.sh.epp"),
mode => '0755',
}

$dbconfig_template = $jira::use_jndi_ds ? {
true => "${module_name}/dbconfig.jndi.xml.epp",
default => "${module_name}/dbconfig.xml.epp"
}
file { "${jira::homedir}/dbconfig.xml":
content => epp('jira/dbconfig.xml.epp'),
content => epp($dbconfig_template),
mode => '0600',
}

Expand All @@ -174,12 +178,12 @@
}

file { "${jira::webappdir}/conf/server.xml":
content => epp('jira/server.xml.epp'),
content => epp("${module_name}/server.xml.epp"),
mode => '0600',
}

file { "${jira::webappdir}/conf/context.xml":
content => epp('jira/context.xml.epp'),
content => epp("${module_name}/context.xml.epp"),
mode => '0600',
}

Expand All @@ -195,7 +199,7 @@

if $jira::datacenter {
file { "${jira::homedir}/cluster.properties":
content => epp('jira/cluster.properties.epp'),
content => epp("${module_name}/cluster.properties.epp"),
mode => '0600',
}
}
Expand Down
54 changes: 50 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
# EHCache configuration for clustered mode
# @param ehcache_object_port
# EHCache configuration for clustered mode
# @param use_jndi_ds
# If true, the database will be configured as JNDI datasource in server.xml and then referenced in dbconfig.xml
# @param jndi_ds_name
# Configures the JNDI datasource name
# @param db
# The kind of database to use.
# @param dbname
Expand Down Expand Up @@ -263,6 +267,15 @@
# undocumented SSO parameter
# @param session_lastvalidation
# undocumented SSO parameter
# @param plugins
# an array of hashes defining custom plugins to install
# a single plugin configuration will has the following form
# installation_name: this name wil be used to install the plugin within jira
# source: url of plugin to be fetched
# username: the username for authentification, if necessary
# password: the password for authentification, if necessary
# checksum: the checksum of the plugin, to determine the need for an upgrade
# checksumtype: the type of checksum used (none|md5|sha1|sha2|sha256|sha384|sha512). (default: none)
# @param jvm_permgen
# Deprecated. Exists to notify users that they're trying to configure a parameter that has no effect
# @param poolsize
Expand Down Expand Up @@ -296,6 +309,8 @@
Optional[Stdlib::Port] $ehcache_listener_port = undef,
Optional[Stdlib::Port] $ehcache_object_port = undef,
# Database Settings
Boolean $use_jndi_ds = false,
String[1] $jndi_ds_name = 'JiraDS',
Enum['postgresql','mysql','sqlserver','oracle','h2'] $db = 'postgresql',
String $dbuser = 'jiraadm',
String $dbpassword = 'mypassword',
Expand Down Expand Up @@ -352,10 +367,9 @@
$service_notify = undef,
$service_subscribe = undef,
# Command to stop jira in preparation to upgrade. This is configurable
# incase the jira service is managed outside of puppet. eg: using the
# in case the jira service is managed outside of puppet. eg: using the
# puppetlabs-corosync module: 'crm resource stop jira && sleep 15'
# Note: the command should return either 0 or 5
# when the service doesn't exist
# Note: the command should return either 0 or 5 when the service doesn't exist
String $stop_jira = 'systemctl stop jira.service && sleep 15',
# Whether to manage the 'check-java.sh' script, and where to retrieve
# the script from.
Expand Down Expand Up @@ -411,8 +425,10 @@
Optional[String] $jvm_permgen = undef,
Optional[Integer[0]] $poolsize = undef,
Optional[Boolean] $enable_connection_pooling = undef,
# plugin installation
Array[Hash] $plugins = [],
) {
# To maintain compatibility with previous behaviour, we check for not-servicedesk instead of specifying the
# To maintain compatibility with previous behaviour, we check for not-servicedesk instead of specifying the
if $product != 'servicedesk' and versioncmp($jira::version, '8.0.0') < 0 {
fail('JIRA versions older than 8.0.0 are no longer supported. Please use an older version of this module to upgrade first.')
}
Expand Down Expand Up @@ -476,4 +492,34 @@
if ($enable_sso) {
class { 'jira::sso': }
}

# install any given library or remove them
$plugins.each |Hash $plugin_data| {
$target = "${jira::webappdir}/atlassian-jira/WEB-INF/lib/${$plugin_data['installation_name']}"
if $plugin_data['ensure'] == 'absent' {
archive {
$target:
ensure => 'absent',
}
} else {
$_target_defaults = {
ensure => 'present',
source => $plugin_data['source'],
checksum => $plugin_data['checksum'],
checksum_type => $plugin_data['checksum_type'],
}
$_username = !empty($plugin_data['username']) ? {
default => {},
true => { username => $plugin_data['username'] }
}
$_password = !empty($plugin_data['password']) ? {
default => {},
true => { password => $plugin_data['password'] }
}
$_plugin_archive = {
$target => $_target_defaults + $_username + $_password
}
create_resources(archive, $_plugin_archive)
}
}
}
9 changes: 5 additions & 4 deletions spec/acceptance/default_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ class { 'jira':
EOS

# jira just takes *ages* to start up :-(
WGET_CMD = 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080'.freeze
apply_manifest(pp, catch_failures: true)
sleep 60
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080', acceptable_exit_codes: [0, 8]
shell WGET_CMD, acceptable_exit_codes: [0, 8]
sleep 60
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080', acceptable_exit_codes: [0, 8]
shell WGET_CMD, acceptable_exit_codes: [0, 8]
sleep 60
apply_manifest(pp_upgrade, catch_failures: true)
sleep 60
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080', acceptable_exit_codes: [0, 8]
shell WGET_CMD, acceptable_exit_codes: [0, 8]
sleep 60
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080', acceptable_exit_codes: [0, 8]
shell WGET_CMD, acceptable_exit_codes: [0, 8]
sleep 60
apply_manifest(pp_upgrade, catch_failures: true)
end
Expand Down
5 changes: 3 additions & 2 deletions spec/acceptance/mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ class { 'jira':
}
EOS

WGET_CMD = 'wget -q --tries=24 --retry-connrefused --read-timeout=10 --no-check-certificate localhost:8081'.freeze
apply_manifest(pp, catch_failures: true)
sleep 60
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 --no-check-certificate localhost:8081', acceptable_exit_codes: [0, 8]
shell WGET_CMD, acceptable_exit_codes: [0, 8]
sleep 60
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 --no-check-certificate localhost:8081', acceptable_exit_codes: [0, 8]
shell WGET_CMD, acceptable_exit_codes: [0, 8]
sleep 60
apply_manifest(pp, catch_changes: true)
end
Expand Down
Loading

0 comments on commit f2f8915

Please sign in to comment.