Skip to content

Commit 2bb207f

Browse files
author
Michael Kluge
committed
Fix facts and test
1 parent 0a7d539 commit 2bb207f

4 files changed

Lines changed: 175 additions & 123 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ Reverse proxy can be configured as a hash as part of the JIRA resource
247247
},
248248
```
249249

250+
### notes on secret encryption in dbconfig.xml
251+
The JIRA process will read the dbconfig.xml on startup replace it with the string "{ATL_SECURED}". The password is moved
252+
into `<shared_homedir>/keys/javax.crypto.spec.SecretKeySpec_<some random number>`. It is important that this directory
253+
is not located inside of the installation dir as you would lose it in the case of an update.
254+
250255
## Reference
251256

252257
see [REFERENCE.md](REFERENCE.md)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# frozen_string_literal: true
2+
3+
Facter.add('jira_service_status') do
4+
setcode do
5+
Facter::Core::Execution.execute('systemctl is-active jira')
6+
end
7+
end
8+
9+
Facter.add('jira_running_pid') do
10+
setcode do
11+
Facter::Core::Execution.execute('systemctl show -p MainPID --value jira')
12+
end
13+
end
14+
15+
Facter.add('jira_running_user') do
16+
setcode do
17+
if Facter.value('jira_service_status') == 'active' && Facter.value('jira_running_pid') != ''
18+
Facter::Core::Execution.execute(format('stat -c %%U /proc/%s', Facter.value('jira_running_pid')))
19+
else
20+
'<unknown>'
21+
end
22+
end
23+
end
24+
25+
Facter.add('jira_running_dbconfig_exists') do
26+
setcode do
27+
if Facter.value('jira_running_user') == '<unknown>'
28+
false
29+
else
30+
File.exist? format('%s/dbconfig.xml', Dir.home(Facter.value('jira_running_user')))
31+
end
32+
end
33+
end
34+
35+
Facter.add('jira_running_version') do
36+
setcode do
37+
if Facter.value('jira_running_user') == '<unknown>'
38+
'<unknown>'
39+
else
40+
Facter::Core::Execution.execute('systemctl show --property ExecStart --value jira | grep -o -E "path=[^ ]+" | grep -o -E "\-[0-9\.]+\-" | tr -d "-"')
41+
end
42+
end
43+
end

manifests/init.pp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,15 @@
484484
fail('You need to specify a value for javahome')
485485
}
486486

487-
$change_dbpassword_real = versioncmp($version, '10.3.0') ? {
488-
-1 => true,
489-
default => $change_dbpassword,
487+
if $facts['jira_running_dbconfig_exists'] {
488+
$change_dbpassword_real = versioncmp($version, '10.3.0') ? {
489+
-1 => true,
490+
default => $change_dbpassword,
491+
}
492+
}
493+
else {
494+
# jira propably not installed
495+
$change_dbpassword_real = true
490496
}
491497

492498
contain jira::install

spec/acceptance/default_parameters_jira_10_spec.rb

Lines changed: 118 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -2,126 +2,124 @@
22

33
require 'spec_helper_acceptance'
44

5-
describe 'jira 10 postgresql' do
6-
it 'installs jira 10 with defaults' do
7-
prepare = <<-EOS
8-
9-
package {'diffutils':
10-
ensure => installed
11-
}
12-
file_line{'enable show_diff':
13-
path => '/etc/puppetlabs/puppet/puppet.conf',
14-
line => 'show_diff = true'
15-
}
16-
EOS
17-
apply_manifest(prepare, catch_failures: true)
18-
19-
pp = <<-EOS
20-
21-
$java_package = $facts['os']['family'] ? {
22-
'RedHat' => 'java-17-openjdk-headless',
23-
'Debian' => 'openjdk-17-jre-headless',
24-
}
25-
26-
$java_home = $facts['os']['family'] ? {
27-
'RedHat' => '/usr/lib/jvm/jre-17-openjdk',
28-
'Debian' => '/usr/lib/jvm/java-1.17.0-openjdk-amd64',
29-
}
30-
31-
# The output of `systemctl status postgresql` is non ascii which
32-
# breaks the Exec in Postgresql::Server::Instance::Reload
33-
# on rhel based docker containers
34-
# We don't need the output.
35-
class { 'postgresql::server':
36-
service_status => 'systemctl status postgresql > /dev/null'
37-
}
38-
39-
postgresql::server::db { 'jira':
40-
user => 'jiraadm',
41-
password => postgresql::postgresql_password('jiraadm', 'mypassword'),
42-
}
43-
44-
# There is a bug in the check-java.sh that prevents jira from starting on Centos Stream 8
45-
# https://jira.atlassian.com/browse/JRASERVER-77097
46-
# Running with script_check_java_manage => true to solve this
47-
class { 'jira':
48-
version => '10.3.2',
49-
change_dbpassword => true,
50-
java_package => $java_package,
51-
javahome => $java_home,
52-
script_check_java_manage => false,
53-
connection_settings => 'tcpKeepAlive=true',
54-
require => Postgresql::Server::Db['jira']
55-
}
56-
EOS
57-
58-
pp_upgrade = <<-EOS
59-
$java_package = $facts['os']['family'] ? {
60-
'RedHat' => 'java-17-openjdk-headless',
61-
'Debian' => 'openjdk-17-jre-headless',
62-
}
63-
64-
$java_home = $facts['os']['family'] ? {
65-
'RedHat' => '/usr/lib/jvm/jre-17-openjdk',
66-
'Debian' => '/usr/lib/jvm/java-1.17.0-openjdk-amd64',
67-
}
68-
69-
class { 'jira':
70-
version => '10.3.3',
71-
change_dbpassword => true,
72-
java_package => $java_package,
73-
javahome => $java_home,
74-
connection_settings => 'tcpKeepAlive=true',
75-
script_check_java_manage => false
76-
}
77-
EOS
78-
79-
# jira just takes *ages* to start up :-(
80-
wget_cmd = 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080'
81-
apply_manifest(pp, catch_failures: true)
82-
sleep SLEEP_SECONDS
83-
shell wget_cmd, acceptable_exit_codes: [0, 8]
84-
sleep SLEEP_SECONDS
85-
shell wget_cmd, acceptable_exit_codes: [0, 8]
86-
pp = pp.gsub(/change_dbpassword.+=> true,/, 'change_dbpassword => false,')
87-
apply_manifest(pp, catch_changes: true)
88-
89-
apply_manifest(pp_upgrade, catch_failures: true)
90-
sleep SLEEP_SECONDS
91-
shell wget_cmd, acceptable_exit_codes: [0, 8]
92-
sleep SLEEP_SECONDS
93-
shell wget_cmd, acceptable_exit_codes: [0, 8]
94-
95-
pp_upgrade = pp_upgrade.gsub(/change_dbpassword.+=> true,/, 'change_dbpassword => false,')
96-
apply_manifest(pp_upgrade, catch_changes: true)
97-
end
98-
99-
describe process('java') do
100-
it { is_expected.to be_running }
101-
end
102-
103-
describe port(8080) do
104-
it { is_expected.to be_listening }
105-
end
106-
107-
describe service('jira') do
108-
it { is_expected.to be_enabled }
109-
it { is_expected.to be_running }
110-
end
111-
112-
describe user('jira') do
113-
it { is_expected.to belong_to_group 'jira' }
114-
it { is_expected.to have_login_shell '/bin/true' }
115-
end
116-
describe command('sleep 1200') do
117-
end
118-
describe command('wget -q --tries=54 --retry-connrefused --read-timeout=10 -O- localhost:8080') do
119-
its(:stdout) { is_expected.to include('10.3.3') }
120-
end
5+
def on_supported_os
6+
(fact('os.family') == 'Debian' and fact('os.release.major') == '11') or (fact('os.family') == 'RedHat' and fact('os.release.major') >= '8')
7+
end
1218

122-
describe 'shutdown' do
123-
it { shell('service jira stop', acceptable_exit_codes: [0, 1]) }
124-
it { shell('pkill -9 -f postgres', acceptable_exit_codes: [0, 1]) }
125-
it { shell('pkill -9 -f jira', acceptable_exit_codes: [0, 1]) }
9+
context 'jira 10 only on RedHat >=8 and Debian-11', if: on_supported_os do
10+
describe 'jira 10 postgresql' do
11+
it 'installs jira 10 with defaults' do
12+
prepare = <<-EOS
13+
package {'diffutils':
14+
ensure => installed
15+
}
16+
file_line{'enable show_diff':
17+
path => '/etc/puppetlabs/puppet/puppet.conf',
18+
line => 'show_diff = true'
19+
}
20+
EOS
21+
apply_manifest(prepare, catch_failures: true)
22+
23+
pre = <<-EOS
24+
if $facts['os']['family'] == 'RedHat' {
25+
$java_package = 'java-17-openjdk'
26+
$java_home = '/usr/lib/jvm/jre-17-openjdk'
27+
$manage_dnf_module = true
28+
}
29+
elsif $facts['os']['family'] == 'Debian' {
30+
$java_package = 'openjdk-17-jre'
31+
$java_home = '/usr/lib/jvm/java-1.17.0-openjdk-amd64'
32+
$manage_dnf_module = false
33+
}
34+
EOS
35+
36+
pp = <<-EOS
37+
# The output of `systemctl status postgresql` is non ascii which
38+
# breaks the Exec in Postgresql::Server::Instance::Reload
39+
# on rhel based docker containers
40+
# We don't need the output.
41+
class { 'postgresql::globals':
42+
manage_dnf_module => $manage_dnf_module,
43+
version => '13',
44+
}
45+
class { 'postgresql::server':
46+
service_status => 'systemctl status postgresql > /dev/null'
47+
}
48+
49+
postgresql::server::db { 'jira':
50+
user => 'jiraadm',
51+
password => postgresql::postgresql_password('jiraadm', 'mypassword'),
52+
}
53+
54+
# There is a bug in the check-java.sh that prevents jira from starting on Centos Stream 8
55+
# https://jira.atlassian.com/browse/JRASERVER-77097
56+
# Running with script_check_java_manage => true to solve this
57+
class { 'jira':
58+
version => '10.3.2',
59+
java_package => $java_package,
60+
javahome => $java_home,
61+
script_check_java_manage => false,
62+
connection_settings => 'tcpKeepAlive=true',
63+
require => Postgresql::Server::Db['jira']
64+
}
65+
EOS
66+
pp = pre + pp
67+
68+
pp_upgrade = <<-EOS
69+
class { 'jira':
70+
version => '10.3.3',
71+
java_package => $java_package,
72+
javahome => $java_home,
73+
connection_settings => 'tcpKeepAlive=true',
74+
script_check_java_manage => false
75+
}
76+
EOS
77+
pp_upgrade = pre + pp_upgrade
78+
79+
# jira just takes *ages* to start up :-(
80+
wget_cmd = 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080'
81+
apply_manifest(pp, catch_failures: true)
82+
sleep SLEEP_SECONDS
83+
shell wget_cmd, acceptable_exit_codes: [0, 8]
84+
sleep SLEEP_SECONDS
85+
shell wget_cmd, acceptable_exit_codes: [0, 8]
86+
apply_manifest(pp, catch_changes: true)
87+
88+
apply_manifest(pp_upgrade, catch_failures: true)
89+
sleep SLEEP_SECONDS
90+
shell wget_cmd, acceptable_exit_codes: [0, 8]
91+
sleep SLEEP_SECONDS
92+
shell wget_cmd, acceptable_exit_codes: [0, 8]
93+
94+
apply_manifest(pp_upgrade, catch_changes: true)
95+
end
96+
97+
describe process('java') do
98+
it { is_expected.to be_running }
99+
end
100+
101+
describe port(8080) do
102+
it { is_expected.to be_listening }
103+
end
104+
105+
describe service('jira') do
106+
it { is_expected.to be_enabled }
107+
it { is_expected.to be_running }
108+
end
109+
110+
describe user('jira') do
111+
it { is_expected.to belong_to_group 'jira' }
112+
it { is_expected.to have_login_shell '/bin/true' }
113+
end
114+
115+
describe command('wget -q --tries=54 --retry-connrefused --read-timeout=10 -O- localhost:8080') do
116+
its(:stdout) { is_expected.to include('10.3.3') }
117+
end
118+
119+
describe 'shutdown' do
120+
it { shell('service jira stop', acceptable_exit_codes: [0, 1]) }
121+
it { shell('pkill -9 -f postgres', acceptable_exit_codes: [0, 1]) }
122+
it { shell('pkill -9 -f jira', acceptable_exit_codes: [0, 1]) }
123+
end
126124
end
127125
end

0 commit comments

Comments
 (0)