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

Drop port 8443 as a reverse proxy #496

Merged
merged 1 commit into from
Oct 22, 2024
Merged
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
36 changes: 9 additions & 27 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
#
# === Advanced parameters:
#
# $reverse_proxy:: Add reverse proxy to the parent
#
# $reverse_proxy_port:: Reverse proxy listening port
#
# $reverse_proxy_backend_protocol:: Configure the protocol used by the reverse proxy to connect to Foreman
#
# $pulpcore_allowed_content_checksums:: List of checksums to use for pulpcore content operations
Expand Down Expand Up @@ -81,8 +77,6 @@
class foreman_proxy_content (
Boolean $pulpcore_mirror = false,

Boolean $reverse_proxy = false,
Stdlib::Port $reverse_proxy_port = 8443,
Enum['h2', 'https'] $reverse_proxy_backend_protocol = 'h2',

Boolean $enable_yum = true,
Expand Down Expand Up @@ -122,7 +116,6 @@

$foreman_url = $foreman_proxy::foreman_base_url
$foreman_host = foreman_proxy_content::host_from_url($foreman_url)
$reverse_proxy_real = $pulpcore_mirror and $reverse_proxy
$proxy_foreman_url = $foreman_url.regsubst('https://', "${reverse_proxy_backend_protocol}://")

# TODO: make it configurable
Expand All @@ -137,15 +130,6 @@
include certs::foreman_proxy
Class['certs::foreman_proxy'] ~> Service['foreman-proxy']

if $reverse_proxy_real {
foreman_proxy_content::reverse_proxy { "rhsm-pulpcore-https-${reverse_proxy_port}":
path_url_map => { '/' => "${proxy_foreman_url}/" },
port => $reverse_proxy_port,
priority => '10',
before => Class['pulpcore::apache'],
}
}

include foreman_proxy_content::pub_dir

if $pulpcore_mirror {
Expand Down Expand Up @@ -252,17 +236,15 @@
require => Class['certs::foreman'],
}
} elsif $pulpcore_mirror {
if $rhsm_port != $reverse_proxy_port {
foreman_proxy_content::reverse_proxy { $apache_https_vhost:
docroot => $pulpcore::apache_docroot,
path_url_map => {
$rhsm_path => "${proxy_foreman_url}${rhsm_path}",
$insights_path => "${proxy_foreman_url}${insights_path}",
},
port => $rhsm_port,
priority => '10',
before => Class['pulpcore::apache'],
}
foreman_proxy_content::reverse_proxy { $apache_https_vhost:
docroot => $pulpcore::apache_docroot,
path_url_map => {
$rhsm_path => "${proxy_foreman_url}${rhsm_path}",
$insights_path => "${proxy_foreman_url}${insights_path}",
},
port => $rhsm_port,
priority => '10',
before => Class['pulpcore::apache'],
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/reverse_proxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
define foreman_proxy_content::reverse_proxy (
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this as a define? Taking a step back, let's look at the whole picture.

This now defines a vhost, but Pulp can also define a vhost. So can Foreman. What this then adds is the RHSM bits, which we also do in puppet-katello.

Perhaps we should capture this as a future refactor, but I feel there's room to improve on alignment here.

On the other hand, they are also conceptually different: with puppet-katello it's actual application code handling things while with puppet-foreman_proxy_content it's forwarded to the real application.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll take a note to have a look at re-factoring this week. That's always a good idea. I think the right answer is to do that after we've done the minimal change to extract this functionality first.

Stdlib::Absolutepath $docroot = '/var/www/html',
Hash[Stdlib::Unixpath, String[1]] $path_url_map = { '/' => "${foreman_proxy_content::foreman_url}/" },
Stdlib::Port $port = $foreman_proxy_content::reverse_proxy_port,
Stdlib::Port $port = 443,
Variant[Array[String], String, Undef] $ssl_protocol = undef,
Hash[String, Any] $vhost_params = {},
Hash[String, Variant[String, Integer]] $proxy_pass_params = { 'disablereuse' => 'on', 'retry' => '0' },
Expand Down
47 changes: 0 additions & 47 deletions spec/acceptance/content_standalone_mirror_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,53 +47,6 @@ class { 'foreman_proxy_content':
end
end

context 'with reverse_proxy true' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<~PUPPET
include certs::foreman_proxy

class { 'foreman_proxy':
register_in_foreman => false,
ssl_ca => $certs::foreman_proxy::proxy_ca_cert,
ssl_cert => $certs::foreman_proxy::proxy_cert,
ssl_key => $certs::foreman_proxy::proxy_key,
}

class { 'foreman_proxy_content':
pulpcore_mirror => true,
reverse_proxy => true,
# No Ansible repo is set up in our CI
enable_ansible => false,
}
PUPPET
end
end

describe service('httpd') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end

describe file('/etc/httpd/conf.d/10-pulpcore.conf') do
it { is_expected.to be_file }
it { is_expected.to contain(%r{DocumentRoot "/var/lib/pulp/pulpcore_static}) }
end

describe file('/etc/httpd/conf.d/10-rhsm-pulpcore-https-443.conf') do
it { is_expected.to be_file }
it { is_expected.to contain('DocumentRoot "/var/lib/pulp/pulpcore_static"') }
end

describe port('443') do
it { is_expected.to be_listening }
end

describe port('8443') do
it { is_expected.to be_listening }
end
end

describe package('rubygem-smart_proxy_container_gateway') do
it { is_expected.to be_installed }
end
Expand Down
17 changes: 0 additions & 17 deletions spec/classes/foreman_proxy_content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,23 +261,6 @@ class { 'certs':
it { is_expected.not_to compile.with_all_deps }
end
end

context 'with deprecated_reverse_proxy_port' do
let(:params) do
{
pulpcore_mirror: true,
reverse_proxy: true,
}
end

it do
is_expected.to contain_foreman_proxy_content__reverse_proxy('rhsm-pulpcore-https-8443')
.with(path_url_map: {'/' => 'h2://foo.example.com/'})
.with(port: 8443)
.with(priority: '10')
.that_comes_before('Class[pulpcore::apache]')
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/defines/foreman_proxy_content__reverse_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
is_expected.to contain_apache__vhost('my-reverse-proxy')
.with_servername(facts[:fqdn])
.with_serveraliases([])
.with_port(8443)
.with_port(443)
.with_proxy_pass([{
'path' => '/',
'url' => "https://#{facts[:fqdn]}/",
Expand Down
Loading