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

BZ1211080 horizon ssl termination #514

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions puppet/modules/quickstack/lib/facter/haproxy_cert_exist.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if FileTest.file?("/etc/ssl/horizon.pem")
Facter.add(:haproxy_cert_exist) do
setcode { true }
end
end
66 changes: 53 additions & 13 deletions puppet/modules/quickstack/manifests/load_balancer/horizon.pp
Original file line number Diff line number Diff line change
@@ -1,29 +1,69 @@
class quickstack::load_balancer::horizon (
$frontend_pub_host,
$frontend_priv_host,
$frontend_admin_host,
$backend_server_names,
$backend_server_addrs,
$port = '80',
$mode = 'http',
$log = 'httplog',
$frontend_pub_host,
$frontend_priv_host,
$frontend_admin_host,
$backend_server_names,
$backend_server_addrs,
$backend_port = '80',
$mode = 'http',
$option = 'httplog'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This becomes $log after the new patch, and we want it to be tcplog for consistency.

) {

include quickstack::load_balancer::common
include quickstack::load_balancer::common

quickstack::load_balancer::proxy { 'horizon':
if str2bool("$::haproxy_cert_exist") {
quickstack::load_balancer::proxy { 'horizon':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not refactor this and the repeated declaration below the if so it is only described once? port could easily stay a variable, since that is different between the ssl/non-ssl versions, and you could just set backend_port to nil/undef (unless this causes haproxy config to be incorrect, but passing undef as the value should be the same as not even calling it, as I understand it). Then you can just use this if block to set those params and perhaps create the horizon_http resource.

addr => [ $frontend_pub_host,
$frontend_priv_host,
$frontend_admin_host ],
port => "$port",
mode => "$mode",

port => "443 ssl crt /etc/ssl/horizon.pem",
mode => $mode,
listen_options => {
'option' => [ "$log" ],
'option' => [ $option ],
'cookie' => 'SERVERID insert indirect nocache',
},
member_options => [ 'check inter 1s' ],
define_cookies => true,
backend_port => $backend_port,
backend_server_addrs => $backend_server_addrs,
backend_server_names => $backend_server_names,
}

quickstack::load_balancer::proxy { 'horizon_http':
addr => [ $frontend_pub_host,
$frontend_priv_host,
$frontend_admin_host ],
port => "80",
mode => $mode,
listen_options => {
'option' => [ $option ],
'reqadd' => 'X-Forwarded-Proto:\ http',
'redirect' => 'scheme https if !{ ssl_fc }',
},
member_options => [ 'check inter 1s' ],
define_cookies => true,
backend_port => $backend_port,
backend_server_addrs => undef,
backend_server_names => undef,
}
}

else {
quickstack::load_balancer::proxy { 'horizon':
addr => [ $frontend_pub_host,
$frontend_priv_host,
$frontend_admin_host ],
port => "80",
mode => "$mode",
listen_options => {
'option' => [ "$option" ],
'cookie' => 'SERVERID insert indirect nocache',
},
member_options => [ 'check inter 1s' ],
define_cookies => true,
backend_server_addrs => $backend_server_addrs,
backend_server_names => $backend_server_names,
}
}
}