Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor most configuration to use EPP templates #354

Merged
merged 14 commits into from
Apr 15, 2021
Merged
6 changes: 6 additions & 0 deletions functions/sort_hash.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @summary Return a sorted hash
# @api private
function jira::sort_hash(Hash $input) >> Hash {
# Puppet hashes are "insertion order", so this works to sort by key
Hash(sort(Array($input)))
}
140 changes: 108 additions & 32 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------------
class jira::config inherits jira {
class jira::config {
# This class should be used from init.pp with a dependency on jira::install
# and sending a refresh to jira::service
assert_private()

File {
owner => $jira::user,
group => $jira::group,
Expand All @@ -27,68 +31,140 @@
# can't use pick_default: https://tickets.puppetlabs.com/browse/MODULES-11018
$dbschema = if $jira::dbschema { $jira::dbschema } else { $dbschema_default }

if $jira::java_opts {
deprecation('jira::java_opts', 'jira::java_opts is deprecated. Please use jira::jvm_extra_args')
$jvm_extra_args_real = "${jira::java_opts} ${jira::jvm_extra_args}"
} else {
$jvm_extra_args_real = $jira::jvm_extra_args
}

# Allow some backwards compatibility;
if $jira::poolsize {
deprecation('jira::poolsize', 'jira::poolsize is deprecated and simply sets max-pool-size. Please use jira::pool_max_size instead and remove this configuration')
$pool_max_size_real = pick($jira::pool_max_size, $jira::poolsize)
} else {
$pool_max_size_real = $jira::pool_max_size
}

if $jira::tomcat_redirect_https_port {
unless $jira::tomcat_native_ssl {
fail('You need to set jira::tomcat_native_ssl to true when using jira::tomcat_redirect_https_port')
}
}

if $jira::dbport {
$dbport_real = $jira::dbport
} else {
$dbport_real = $jira::db ? {
'postgresql' => '5432',
'mysql' => '3306',
'oracle' => '1521',
'sqlserver' => '1433',
'h2' => '',
}
}

if $jira::dbdriver {
$dbdriver_real = $jira::dbdriver
} else {
$dbdriver_real = $jira::db ? {
'postgresql' => 'org.postgresql.Driver',
'mysql' => 'com.mysql.jdbc.Driver',
'oracle' => 'oracle.jdbc.OracleDriver',
'sqlserver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
'h2' => 'org.h2.Driver',
}
}

if $jira::dbtype {
$dbtype_real = $jira::dbtype
} else {
$dbtype_real = $jira::db ? {
'postgresql' => 'postgres72',
'mysql' => 'mysql',
'oracle' => 'oracle10g',
'sqlserver' => 'mssql',
'h2' => 'h2',
}
}

if $jira::dburl {
$dburl_real = $jira::dburl
}
else {
$dburl_real = $jira::db ? {
'postgresql' => "jdbc:${jira::db}://${jira::dbserver}:${dbport_real}/${jira::dbname}",
'mysql' => "jdbc:${jira::db}://${jira::dbserver}:${dbport_real}/${jira::dbname}?useUnicode=true&characterEncoding=UTF8&sessionVariables=default_storage_engine=InnoDB",
'oracle' => "jdbc:${jira::db}:thin:@${jira::dbserver}:${dbport_real}:${jira::dbname}",
'sqlserver' => "jdbc:jtds:${jira::db}://${jira::dbserver}:${dbport_real}/${jira::dbname}",
'h2' => "jdbc:h2:file:/${jira::homedir}/database/${jira::dbname}",
}
}

if $jira::tomcat_protocol_ssl {
$tomcat_protocol_ssl_real = $jira::tomcat_protocol_ssl
} else {
if versioncmp($jira::version, '7.3.0') >= 0 {
$tomcat_protocol_ssl_real = 'org.apache.coyote.http11.Http11NioProtocol'
} else {
$tomcat_protocol_ssl_real = 'org.apache.coyote.http11.Http11Protocol'
}
}

$jira_properties = {
'jira.websudo.is.disabled' => !$jira::enable_secure_admin_sessions,
}
$merged_jira_config_properties = jira::sort_hash($jira_properties + $jira::jira_config_properties)

# Configuration logic ends, resources begin:

file { "${jira::webappdir}/bin/user.sh":
content => template('jira/user.sh.erb'),
content => epp('jira/user.sh.epp'),
mode => '0755',
require => [
Class['jira::install'],
File[$jira::webappdir],
File[$jira::homedir],
],
}

-> file { "${jira::webappdir}/bin/setenv.sh":
content => template('jira/setenv.sh.erb'),
file { "${jira::webappdir}/bin/setenv.sh":
content => epp('jira/setenv.sh.epp'),
mode => '0755',
require => Class['jira::install'],
notify => Class['jira::service'],
}

-> file { "${jira::homedir}/dbconfig.xml":
file { "${jira::homedir}/dbconfig.xml":
content => epp('jira/dbconfig.xml.epp'),
mode => '0600',
require => [Class['jira::install'],File[$jira::homedir]],
notify => Class['jira::service'],
}

if $jira::script_check_java_manage {
file { "${jira::webappdir}/bin/check-java.sh":
content => template($jira::script_check_java_template),
mode => '0755',
require => [
Class['jira::install'],
File["${jira::webappdir}/bin/setenv.sh"],
],
notify => Class['jira::service'],
require => File["${jira::webappdir}/bin/setenv.sh"],
}
}

file { "${jira::webappdir}/conf/server.xml":
content => template('jira/server.xml.erb'),
content => epp('jira/server.xml.epp'),
mode => '0600',
require => Class['jira::install'],
notify => Class['jira::service'],
}
-> file { "${jira::webappdir}/conf/context.xml":
content => template('jira/context.xml.erb'),

file { "${jira::webappdir}/conf/context.xml":
content => epp('jira/context.xml.epp'),
mode => '0600',
require => Class['jira::install'],
notify => Class['jira::service'],
}

file { "${jira::homedir}/jira-config.properties":
content => template('jira/jira-config.properties.erb'),
content => inline_epp(@(EOF)
<% $merged_jira_config_properties.each |$key, $val| { -%>
<%= $key %> = <%= $val %>
<%- } -%>
| EOF
),
mode => '0600',
require => [Class['jira::install'],File[$jira::homedir]],
notify => Class['jira::service'],
}

if $jira::datacenter {
file { "${jira::homedir}/cluster.properties":
content => template('jira/cluster.properties.erb'),
content => epp('jira/cluster.properties.epp'),
mode => '0600',
require => [Class['jira::install'],File[$jira::homedir]],
notify => Class['jira::service'],
}
}
}
2 changes: 1 addition & 1 deletion manifests/facts.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

file { "${dir}/facts.d/jira_facts.rb":
ensure => $ensure,
content => template('jira/facts.rb.erb'),
content => epp('jira/facts.rb.epp'),
mode => '0755',
}
}
76 changes: 0 additions & 76 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,6 @@
deprecation('jira::enable_connection_pooling', 'jira::enable_connection_pooling has been removed and does nothing. Please simply configure the connection pooling parameters')
}

if $java_opts {
deprecation('jira::java_opts', 'jira::java_opts is deprecated. Please use jira::jvm_extra_args')
$jvm_extra_args_real = "${java_opts} ${jvm_extra_args}"
} else {
$jvm_extra_args_real = $jvm_extra_args
}

# Allow some backwards compatibility;
if $poolsize {
deprecation('jira::poolsize', 'jira::poolsize is deprecated and simply sets max-pool-size. Please use jira::pool_max_size instead and remove this configuration')
$pool_max_size_real = pick($pool_max_size, $poolsize)
} else {
$pool_max_size_real = $pool_max_size
}

if $tomcat_redirect_https_port {
unless ($tomcat_native_ssl) {
fail('You need to set native_ssl to true when using tomcat_redirect_https_port')
Expand Down Expand Up @@ -218,65 +203,6 @@
$webappdir = $extractdir
}

if $dbport {
$dbport_real = $dbport
} else {
$dbport_real = $db ? {
'postgresql' => '5432',
'mysql' => '3306',
'oracle' => '1521',
'sqlserver' => '1433',
'h2' => '',
}
}

if $dbdriver {
$dbdriver_real = $dbdriver
} else {
$dbdriver_real = $db ? {
'postgresql' => 'org.postgresql.Driver',
'mysql' => 'com.mysql.jdbc.Driver',
'oracle' => 'oracle.jdbc.OracleDriver',
'sqlserver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
'h2' => 'org.h2.Driver',
}
}

if $dbtype {
$dbtype_real = $dbtype
} else {
$dbtype_real = $db ? {
'postgresql' => 'postgres72',
'mysql' => 'mysql',
'oracle' => 'oracle10g',
'sqlserver' => 'mssql',
'h2' => 'h2',
}
}

if $dburl {
$dburl_real = $dburl
}
else {
$dburl_real = $db ? {
'postgresql' => "jdbc:${db}://${dbserver}:${dbport_real}/${dbname}",
'mysql' => "jdbc:${db}://${dbserver}:${dbport_real}/${dbname}?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=default_storage_engine=InnoDB",
'oracle' => "jdbc:${db}:thin:@${dbserver}:${dbport_real}:${dbname}",
'sqlserver' => "jdbc:jtds:${db}://${dbserver}:${dbport_real}/${dbname}",
'h2' => "jdbc:h2:file:/${jira::homedir}/database/${dbname}",
}
}

if $tomcat_protocol_ssl {
$tomcat_protocol_ssl_real = $tomcat_protocol_ssl
} else {
if versioncmp($version, '7.3.0') >= 0 {
$tomcat_protocol_ssl_real = 'org.apache.coyote.http11.Http11NioProtocol'
} else {
$tomcat_protocol_ssl_real = 'org.apache.coyote.http11.Http11Protocol'
}
}

if ! empty($ajp) {
if ! ('port' in $ajp) {
fail('You need to specify a valid port for the AJP connector.')
Expand All @@ -290,8 +216,6 @@
}
}

$merged_jira_config_properties = merge( { 'jira.websudo.is.disabled' => !$enable_secure_admin_sessions }, $jira_config_properties)

if $javahome == undef {
fail('You need to specify a value for javahome')
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/sso.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
) {
file { "${jira::webappdir}/atlassian-jira/WEB-INF/classes/crowd.properties":
ensure => file,
content => template('jira/crowd.properties'),
content => epp('jira/crowd.properties.epp'),
mode => '0660',
owner => $jira::user,
group => $jira::group,
Expand Down
13 changes: 13 additions & 0 deletions templates/cluster.properties.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This ID must be unique across the cluster
jira.node.id = <%= $facts['fqdn'] %>
# The location of the shared home directory for all JIRA nodes
jira.shared.home = <%= $jira::shared_homedir %>
<% if $jira::ehcache_listener_host { -%>
ehcache.listener.hostName = <%= $jira::ehcache_listener_host %>
<% } -%>
<% if $jira::ehcache_listener_port { -%>
ehcache.listener.port = <%= $jira::ehcache_listener_port %>
<% } -%>
<% if $jira::ehcache_object_port { -%>
ehcache.object.port = <%= $jira::ehcache_object_port %>
<% } -%>
13 changes: 0 additions & 13 deletions templates/cluster.properties.erb

This file was deleted.

14 changes: 6 additions & 8 deletions templates/context.xml.erb → templates/context.xml.epp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->

<% if ! scope.lookupvar('jira::resources').empty? -%>
<% scope.lookupvar('jira::resources').each do |name, values| -%>
<Resource name = "<%= name %>"
<% values.each_pair do |key,value| -%>
<%= key %> = <%= "\"#{value}\"" %>
<% end -%>
<% jira::sort_hash($jira::resources).each |$name, $values| { -%>
<Resource name = "<%= $name %>"
<% jira::sort_hash($values).each |$key, $value| { -%>
<%= $key %> = "<%= $value %>"
<% } -%>
/>
<% end -%>
<% end -%>
<% } -%>
<JarScanner scanManifest="false"/>
</Context>
11 changes: 0 additions & 11 deletions templates/crowd.properties

This file was deleted.

11 changes: 11 additions & 0 deletions templates/crowd.properties.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
application.name <%= $jira::sso::application_name %>
application.password <%= $jira::sso::application_password %>
application.login.url <%= $jira::sso::application_login_url %>

crowd.server.url <%= $jira::sso::crowd_server_url %>
crowd.base.url <%= $jira::sso::crowd_base_url %>

session.isauthenticated <%= $jira::sso::session_isauthenticated %>
session.tokenkey <%= $jira::sso::session_tokenkey %>
session.validationinterval <%= $jira::sso::session_validationinterval %>
session.lastvalidation <%= $jira::sso::session_lastvalidation %>
Loading