22
33require 'spec_helper_acceptance'
44
5- prepare = <<-EOS
6- # package {'diffutils':
7- # ensure => installed
8- # }
9- # file_line{'enable show_diff':
10- # path => '/etc/puppetlabs/puppet/puppet.conf',
11- # line => 'show_diff = true'
12- # }
13- EOS
14-
155pre = <<-EOS
166 if $facts['os']['family'] == 'RedHat' {
177 $java_package = 'java-17-openjdk'
188 $java_home = '/usr/lib/jvm/jre-17-openjdk'
199 $postgresql_version = '13'
2010 $pgsql_package_name = 'postgresql-server'
2111 $pgsql_data_dir = '/var/lib/pgsql'
12+
2213 $manage_dnf_module = $facts['os']['release']['major'] ? {
23- '8' => true,
24- default => false # RHEL-9 has pgsql 13 as a default
14+ '8' => true,
15+ default => false, # RHEL-9 has pgsql 13 as a default
2516 }
17+
2618 $autoremove_command = 'dnf --exclude="systemd*" autoremove -y'
27- }
28- elsif $facts['os']['family'] == 'Debian' {
19+ } elsif $facts['os']['family'] == 'Debian' {
2920 $postgresql_version = $facts['os']['release']['major'] ? {
3021 '11' => '13',
31- default => '14'
22+ default => '14',
3223 }
24+
3325 $java_package = 'openjdk-17-jre'
3426 $java_home = '/usr/lib/jvm/java-17-openjdk-amd64'
3527 $pgsql_package_name = "postgresql-${postgresql_version}"
3628 $pgsql_data_dir = "/var/lib/postgresql/${postgresql_version}/main/"
3729 $manage_dnf_module = false
3830 $autoremove_command = 'apt autoremove -y'
3931 }
32+
4033 $jira_install_dir = '/opt/jira/'
4134 $postgres_service = 'postgresql'
4235 $jira_service = 'jira'
@@ -51,9 +44,10 @@ class { 'postgresql::globals':
5144 manage_dnf_module => $manage_dnf_module,
5245 version => $postgresql_version,
5346 }
47+
5448 class { 'postgresql::server':
5549 service_status => 'systemctl status postgresql > /dev/null',
56- needs_initdb => true
50+ needs_initdb => true,
5751 }
5852
5953 postgresql::server::db { 'jira':
@@ -70,9 +64,10 @@ class { 'jira':
7064 javahome => $java_home,
7165 script_check_java_manage => false,
7266 connection_settings => 'tcpKeepAlive=true',
73- require => Postgresql::Server::Db['jira']
67+ require => Postgresql::Server::Db['jira'],
7468 }
7569EOS
70+
7671pp = pre + pp
7772
7873pp_upgrade = <<-EOS
@@ -81,50 +76,58 @@ class { 'jira':
8176 java_package => $java_package,
8277 javahome => $java_home,
8378 connection_settings => 'tcpKeepAlive=true',
84- script_check_java_manage => false
79+ script_check_java_manage => false,
8580 }
8681EOS
82+
8783pp_upgrade = pre + pp_upgrade
8884
8985pp_remove = <<-EOS
90- package {$java_package:
91- ensure => purged
86+ package { $java_package:
87+ ensure => purged,
9288 }
93- exec {'clear JIRA home':
94- command => 'rm -Rf ~jira/*',
89+
90+ exec { 'clear JIRA home':
91+ command => 'rm -Rf ~jira/*',
9592 provider => shell,
9693 }
97- package {$pgsql_package_name:
98- ensure => purged
94+
95+ package { $pgsql_package_name:
96+ ensure => purged,
9997 }
98+
10099 if $manage_dnf_module {
101- exec {" dnf module reset postgresql" :
102- command => 'dnf module reset -y postgresql',
100+ exec { ' dnf module reset postgresql' :
101+ command => 'dnf module reset -y postgresql',
103102 provider => shell,
104103 }
105104 }
106- exec {"autoremove cleanup":
107- command => $autoremove_command,
105+
106+ exec { 'autoremove cleanup':
107+ command => $autoremove_command,
108108 provider => shell,
109109 }
110- exec {'cleanup pgsql and JIRA install dir':
111- command => "rm -Rf ${pgsql_data_dir}/* ${$jira_install_dir}/atlassian-jira-software*",
110+
111+ exec { 'cleanup pgsql and JIRA install dir':
112+ command => "rm -Rf ${pgsql_data_dir}/* ${$jira_install_dir}/atlassian-jira-software*",
112113 provider => shell,
113- require => Exec['autoremove cleanup'],
114+ require => Exec['autoremove cleanup'],
114115 }
115- service{$postgres_service:
116- ensure => stopped
116+
117+ service { $postgres_service:
118+ ensure => stopped,
117119 }
118- service{$jira_service:
119- ensure => stopped
120+
121+ service { $jira_service:
122+ ensure => stopped,
120123 }
121124EOS
125+
122126pp_remove = pre + pp_remove
123127
124128context 'jira 10' do
125129 describe 'jira 10 postgresql' do
126130 it 'installs jira 10 with defaults' do
127- apply_manifest ( prepare , catch_failures : true )
128131 # jira just takes *ages* to start up :-(
129132 wget_cmd = 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080'
130133 apply_manifest ( pp , catch_failures : true )
@@ -173,7 +176,7 @@ class { 'jira':
173176 apply_manifest ( pp_remove , catch_failures : true )
174177 end
175178
176- it { shell ( 'service jira stop' , acceptable_exit_codes : [ 0 , 1 ] ) }
179+ it { shell ( 'systemctl stop jira ' , acceptable_exit_codes : [ 0 , 1 ] ) }
177180 it { shell ( 'pkill -9 -f postgres' , acceptable_exit_codes : [ 0 , 1 ] ) }
178181 it { shell ( 'pkill -9 -f jira' , acceptable_exit_codes : [ 0 , 1 ] ) }
179182 end
0 commit comments