From b436677c85575edf868338fd010f1e44bb3adad8 Mon Sep 17 00:00:00 2001 From: ianballou Date: Mon, 25 Jan 2021 13:18:34 -0500 Subject: [PATCH] Fixes #31642 - Add container gateway support --- manifests/plugin/container_gateway.pp | 37 +++++++++++++++ ...n_proxy__plugin__container_gateway_spec.rb | 45 +++++++++++++++++++ templates/plugin/container_gateway.yml.erb | 7 +++ 3 files changed, 89 insertions(+) create mode 100644 manifests/plugin/container_gateway.pp create mode 100644 spec/classes/foreman_proxy__plugin__container_gateway_spec.rb create mode 100644 templates/plugin/container_gateway.yml.erb diff --git a/manifests/plugin/container_gateway.pp b/manifests/plugin/container_gateway.pp new file mode 100644 index 000000000..0d8bd4950 --- /dev/null +++ b/manifests/plugin/container_gateway.pp @@ -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, + } +} diff --git a/spec/classes/foreman_proxy__plugin__container_gateway_spec.rb b/spec/classes/foreman_proxy__plugin__container_gateway_spec.rb new file mode 100644 index 000000000..16aaff113 --- /dev/null +++ b/spec/classes/foreman_proxy__plugin__container_gateway_spec.rb @@ -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 diff --git a/templates/plugin/container_gateway.yml.erb b/templates/plugin/container_gateway.yml.erb new file mode 100644 index 000000000..f0ffda609 --- /dev/null +++ b/templates/plugin/container_gateway.yml.erb @@ -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") %>