Skip to content

Commit bb1b495

Browse files
committed
Allow defining additional Tomcat connectors
Add a new, optional class parameter `confluence::tomcat_additional_connectors` whose value is a well-formed, complex hash as described by the new type aliases `Confluence::Tomcat_connectors` and `Confluence::Tomcat_attributes`. Each hash key represents a port number, and the key's value is a hash that describes the connector's attributes and their values. Useful for defining additional HTTP ports through which to access Confluence. A typical use case is when Jira and Confluence run behind a reverse proxy and application links between Jira and Confluence must be set up. Then it is often better to allow Jira and Confluence to communicate directly instead of through the reverse proxy, but this requires a Tomcat connector that is configured for direct access instead of reverse proxy access (`proxyName`, `proxyPort`, etc). Described here: https://confluence.atlassian.com/kb/how-to-create-an-unproxied-application-link-719095740.html Contains spec tests, documentation and examples. A very similar PR was submitted to puppet-jira in voxpupuli/puppet-jira#316
1 parent 9d7eedd commit bb1b495

8 files changed

Lines changed: 195 additions & 1 deletion

File tree

manifests/config.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
$manage_server_xml = $confluence::manage_server_xml,
1212
$context_path = $confluence::context_path,
1313
$ajp = $confluence::ajp,
14+
# Additional connectors in server.xml
15+
Confluence::Tomcat_connectors $tomcat_additional_connectors = $confluence::tomcat_additional_connectors,
1416
) {
1517

1618
File {

manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
$context_path = '',
4545
# Options for the AJP connector
4646
Hash $ajp = {},
47+
# Additional connectors in server.xml
48+
Confluence::Tomcat_connectors $tomcat_additional_connectors = {},
4749
# Command to stop confluence in preparation to updgrade. This is configurable
4850
# incase the confluence service is managed outside of puppet. eg: using the
4951
# puppetlabs-corosync module: 'crm resource stop confluence && sleep 15'

spec/classes/confluence_config_spec.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,54 @@
127127
end
128128
end
129129

130+
context 'tomcat additional connectors' do
131+
let(:params) do
132+
{
133+
version: '5.5.6',
134+
javahome: '/opt/java',
135+
manage_server_xml: 'template',
136+
tomcat_additional_connectors: {
137+
8081 => {
138+
'URIEncoding' => 'UTF-8',
139+
'connectionTimeout' => '20000',
140+
'protocol' => 'HTTP/1.1',
141+
'proxyName' => 'foo.example.com',
142+
'proxyPort' => '8123',
143+
'secure' => true,
144+
'scheme' => 'https'
145+
},
146+
8082 => {
147+
'URIEncoding' => 'UTF-8',
148+
'connectionTimeout' => '20000',
149+
'protocol' => 'HTTP/1.1',
150+
'proxyName' => 'bar.example.com',
151+
'proxyPort' => '8124',
152+
'scheme' => 'http'
153+
}
154+
}
155+
}
156+
end
157+
158+
it do
159+
is_expected.to contain_file('/opt/confluence/atlassian-confluence-5.5.6/conf/server.xml').
160+
with_content(%r{<Connector port="8081"}).
161+
with_content(%r{connectionTimeout="20000"}).
162+
with_content(%r{protocol="HTTP/1\.1"}).
163+
with_content(%r{proxyName="foo\.example\.com"}).
164+
with_content(%r{proxyPort="8123"}).
165+
with_content(%r{scheme="https"}).
166+
with_content(%r{secure="true"}).
167+
with_content(%r{URIEncoding="UTF-8"}).
168+
with_content(%r{<Connector port="8082"}).
169+
with_content(%r{connectionTimeout="20000"}).
170+
with_content(%r{protocol="HTTP/1\.1"}).
171+
with_content(%r{proxyName="bar\.example\.com"}).
172+
with_content(%r{proxyPort="8124"}).
173+
with_content(%r{scheme="http"}).
174+
with_content(%r{URIEncoding="UTF-8"})
175+
end
176+
end
177+
130178
context 'catalina_opts set to a string' do
131179
let(:params) do
132180
{
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
require 'spec_helper'
2+
3+
describe 'Confluence::Tomcat_attributes' do
4+
describe 'valid attributes' do
5+
[
6+
{ 'URIEncoding' => 'UTF-8' },
7+
{ 'secure' => true },
8+
{ 'proxyPort' => 8443 },
9+
{
10+
'URIEncoding' => 'UTF-8',
11+
'connectionTimeout' => '20000',
12+
'protocol' => 'HTTP/1.1',
13+
'proxyName' => 'foo.example.com',
14+
'proxyPort' => '8123',
15+
'secure' => true,
16+
'scheme' => 'https'
17+
},
18+
{}
19+
].each do |value|
20+
describe value.inspect do
21+
it { is_expected.to allow_value(value) }
22+
end
23+
end
24+
end
25+
26+
describe 'invalid attributes' do
27+
context 'with garbage inputs' do
28+
[
29+
{ %w[foo blah] => 'bar' },
30+
{ true => 'false' },
31+
{ 'proxyPort' => %w[8443 1234] },
32+
{ 'schema' => { 'https' => 'false' } },
33+
true,
34+
false,
35+
:keyword,
36+
nil,
37+
%w[yes no],
38+
'',
39+
'ネット',
40+
'55555',
41+
'0x123',
42+
'yess',
43+
'nooo'
44+
].each do |value|
45+
describe value.inspect do
46+
it { is_expected.not_to allow_value(value) }
47+
end
48+
end
49+
end
50+
end
51+
end
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
require 'spec_helper'
2+
3+
describe 'Confluence::Tomcat_connectors' do
4+
describe 'valid connector specifications' do
5+
[
6+
{
7+
8081 => {
8+
'URIEncoding' => 'UTF-8',
9+
'connectionTimeout' => '20000',
10+
'protocol' => 'HTTP/1.1',
11+
'proxyName' => 'foo.example.com',
12+
'proxyPort' => '80',
13+
'secure' => false,
14+
'scheme' => 'http'
15+
},
16+
8443 => {
17+
'URIEncoding' => 'UTF-8',
18+
'connectionTimeout' => '20000',
19+
'protocol' => 'HTTP/1.1',
20+
'proxyName' => 'foo.example.com',
21+
'proxyPort' => '443',
22+
'secure' => true,
23+
'scheme' => 'https'
24+
}
25+
}
26+
].each do |value|
27+
describe value.inspect do
28+
it { is_expected.to allow_value(value) }
29+
end
30+
end
31+
end
32+
33+
describe 'invalid connector specifications' do
34+
context 'with garbage inputs' do
35+
[
36+
{
37+
'8081' => {
38+
'URIEncoding' => 'UTF-8',
39+
'connectionTimeout' => '20000',
40+
'protocol' => 'HTTP/1.1',
41+
'proxyName' => 'foo.example.com',
42+
'proxyPort' => '80',
43+
'secure' => false,
44+
'scheme' => 'http'
45+
}
46+
},
47+
{
48+
1023 => {
49+
'URIEncoding' => 'UTF-8',
50+
'connectionTimeout' => '20000',
51+
'protocol' => 'HTTP/1.1',
52+
'proxyName' => 'foo.example.com',
53+
'proxyPort' => '80',
54+
'secure' => false,
55+
'scheme' => 'http'
56+
}
57+
},
58+
{ %w[foo blah] => 'bar' },
59+
{ true => 'false' },
60+
{ 'proxyPort' => %w[8443 1234] },
61+
{ 'schema' => { 'https' => 'false' } },
62+
true,
63+
false,
64+
:keyword,
65+
nil,
66+
%w[yes no],
67+
'',
68+
'ネット',
69+
'55555',
70+
'0x123',
71+
'yess',
72+
'nooo'
73+
].each do |value|
74+
describe value.inspect do
75+
it { is_expected.not_to allow_value(value) }
76+
end
77+
end
78+
end
79+
end
80+
end

templates/server.xml.erb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<% @tomcat_proxy.sort.each do |key,value| -%>
1717
<%= key %>=<%= "\"#{value}\"" %>
1818
<% end -%>
19-
<% end -%>
19+
<% end -%>
2020
/>
2121

2222
<% if @ajp and ! @ajp.empty? -%>
@@ -25,6 +25,15 @@
2525
<%= key %> = <%= "\"#{value}\"" %>
2626
<% end -%>
2727
/>
28+
<% end -%>
29+
<% if @tomcat_additional_connectors and ! @tomcat_additional_connectors.empty? -%>
30+
<% @tomcat_additional_connectors.sort.map do |port, attrs| -%>
31+
<Connector port="<%= port -%>"
32+
<% attrs.sort.map do |key, value| -%>
33+
<%= key -%>="<%= value -%>"
34+
<% end -%>
35+
/>
36+
<% end -%>
2837
<% end -%>
2938

3039
<Engine name="Standalone" defaultHost="localhost" debug="0">

types/tomcat_attributes.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Confluence::Tomcat_attributes = Hash[String[1], Scalar]

types/tomcat_connectors.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Confluence::Tomcat_connectors = Hash[Stdlib::Port::Unprivileged, Confluence::Tomcat_attributes]

0 commit comments

Comments
 (0)