Skip to content

Commit

Permalink
Fixes #31642 - Add container gateway support
Browse files Browse the repository at this point in the history
  • Loading branch information
ianballou committed Feb 1, 2021
1 parent e4b7763 commit b436677
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
37 changes: 37 additions & 0 deletions manifests/plugin/container_gateway.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# = Foreman Proxy Container Gateway plugin
#
# This class installs the Container Gateway plugin
#
# $pulp_endpoint:: Pulp 3 server endpoint
#
# $pulp_client_ssl_cert:: X509 certificate for authenticating with Pulp
#
# $pulp_client_ssl_key:: RSA private key for the Pulp certificate
#
# $sqlite_db_path:: Absolute path for the SQLite DB file to exist at
#
# === Advanced parameters:
#
# $enabled:: enables/disables the pulp plugin
#
# $listen_on:: proxy feature listens on http, https, or both
#
# $version:: plugin package version, it's passed to ensure parameter of package resource
# can be set to specific version number, 'latest', 'present' etc.
#
class foreman_proxy::plugin::container_gateway (
Optional[String] $version = undef,
Boolean $enabled = true,
Foreman_proxy::ListenOn $listen_on = 'https',
Stdlib::HTTPUrl $pulp_endpoint = "https://${facts['networking']['fqdn']}",
Stdlib::Absolutepath $pulp_client_ssl_cert = $foreman_proxy::foreman_ssl_cert,
Stdlib::Absolutepath $pulp_client_ssl_key = $foreman_proxy::foreman_ssl_key,
Stdlib::Absolutepath $sqlite_db_path = '/var/lib/foreman-proxy/smart_proxy_container_gateway.db',
) {
foreman_proxy::plugin::module { 'container_gateway':
version => $version,
enabled => $enabled,
feature => 'Container_Gateway',
listen_on => $listen_on,
}
}
45 changes: 45 additions & 0 deletions spec/classes/foreman_proxy__plugin__container_gateway_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'spec_helper'

describe 'foreman_proxy::plugin::container_gateway' do
on_plugin_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
let(:pre_condition) { 'include foreman_proxy' }

describe 'with default settings' do
it { should contain_foreman_proxy__plugin__module('container_gateway') }
it 'container_gateway.yml should contain the correct configuration' do
verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/container_gateway.yml', [
'---',
':enabled: https',
":pulp_endpoint: https://#{facts[:fqdn]}",
':pulp_client_ssl_cert: /etc/foreman-proxy/foreman_ssl_cert.pem',
':pulp_client_ssl_key: /etc/foreman-proxy/foreman_ssl_key.pem',
':sqlite_db_path: /var/lib/foreman-proxy/smart_proxy_container_gateway.db'
])
end
end

describe 'with overwritten parameters' do
let :params do {
:enabled => true,
:pulp_endpoint => 'https://test.example.com',
:pulp_client_ssl_cert => '/dev/random-cert.pem',
:pulp_client_ssl_key => '/dev/random-key.pem',
:sqlite_db_path => '/dev/null.db',
} end

it 'container_gateway.yml should contain the correct configuration' do
verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/container_gateway.yml', [
'---',
':enabled: true',
':pulp_endpoint: https://test.example.com',
':pulp_client_ssl_cert: /dev/random-cert.pem',
':pulp_client_ssl_key: /dev/random-key.pem',
':sqlite_db_path: /dev/null.db'
])
end
end
end
end
end
7 changes: 7 additions & 0 deletions templates/plugin/container_gateway.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Container Gateway for Katello
:enabled: <%= @module_enabled %>
:pulp_endpoint: <%= scope.lookupvar("foreman_proxy::plugin::container_gateway::pulp_endpoint") %>
:pulp_client_ssl_cert: <%= scope.lookupvar("foreman_proxy::plugin::container_gateway::pulp_client_ssl_cert") %>
:pulp_client_ssl_key: <%= scope.lookupvar("foreman_proxy::plugin::container_gateway::pulp_client_ssl_key") %>
:sqlite_db_path: <%= scope.lookupvar("foreman_proxy::plugin::container_gateway::sqlite_db_path") %>

0 comments on commit b436677

Please sign in to comment.