Skip to content

Commit

Permalink
Update Pulp plugin to drop Pulp 2
Browse files Browse the repository at this point in the history
Katello 4.0 drops Pulp 2 in favor of Pulp 3 completely. If this
plugin is used, then Pulpcore will be used and the user can decide
if it should be deployed as a mirror configuration or not. This drops
most of the parameters as they are not relevant with Pulp 3.
  • Loading branch information
ehelms committed Dec 17, 2020
1 parent 704b729 commit addaa8b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 124 deletions.
48 changes: 10 additions & 38 deletions manifests/plugin/pulp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@
#
# === 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.
#
# $pulp_url:: pulp url to use
#
# $pulp_dir:: directory for pulp
#
# $pulp_content_dir:: directory for pulp content
#
# $pulpnode_enabled:: enables/disables the pulpnode plugin
#
# $pulpcore_enabled:: enables/disables the pulpcore plugin
#
# $pulpcore_mirror:: Whether this pulpcore plugin acts as a mirror or another pulp node. A pulpcore mirror is the pulpcore equivalent of a pulpnode.
Expand All @@ -27,43 +17,19 @@
#
# $pulpcore_content_url:: The URL to the Pulp 3 content
#
# $puppet_content_dir:: Directory for puppet content. Automatically determined if empty.
#
# $mongodb_dir:: directory for Mongo DB
#
class foreman_proxy::plugin::pulp (
Boolean $enabled = $foreman_proxy::plugin::pulp::params::enabled,
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::plugin::pulp::params::listen_on,
Boolean $pulpnode_enabled = $foreman_proxy::plugin::pulp::params::pulpnode_enabled,
Boolean $pulpcore_enabled = $foreman_proxy::plugin::pulp::params::pulpcore_enabled,
Foreman_proxy::ListenOn $listen_on = 'https',
Boolean $pulpcore_enabled = true,
Boolean $pulpcore_mirror = false,
Stdlib::HTTPUrl $pulpcore_api_url = $foreman_proxy::plugin::pulp::params::pulpcore_api_url,
Stdlib::HTTPUrl $pulpcore_content_url = $foreman_proxy::plugin::pulp::params::pulpcore_content_url,
Boolean $pulpcore_mirror = $foreman_proxy::plugin::pulp::params::pulpcore_mirror,
Optional[String] $version = $foreman_proxy::plugin::pulp::params::version,
Stdlib::HTTPUrl $pulp_url = $foreman_proxy::plugin::pulp::params::pulp_url,
Stdlib::Absolutepath $pulp_dir = $foreman_proxy::plugin::pulp::params::pulp_dir,
Stdlib::Absolutepath $pulp_content_dir = $foreman_proxy::plugin::pulp::params::pulp_content_dir,
Optional[Stdlib::Absolutepath] $puppet_content_dir = $foreman_proxy::plugin::pulp::params::puppet_content_dir,
Stdlib::Absolutepath $mongodb_dir = $foreman_proxy::plugin::pulp::params::mongodb_dir,
Optional[String] $version = undef,
) inherits foreman_proxy::plugin::pulp::params {
$real_puppet_content_dir = pick($puppet_content_dir, lookup('puppet::server_envs_dir') |$key| { undef }, $facts['puppet_environmentpath'], "${foreman_proxy::puppetcodedir}/environments")

foreman_proxy::plugin {'pulp':
version => $version,
}
-> [
foreman_proxy::module { 'pulp':
template_path => 'foreman_proxy/plugin/pulp.yml.erb',
enabled => $enabled,
feature => 'Pulp',
listen_on => $listen_on,
},
foreman_proxy::module { 'pulpnode':
template_path => 'foreman_proxy/plugin/pulpnode.yml.erb',
enabled => $pulpnode_enabled,
feature => 'Pulp Node',
listen_on => $listen_on,
},
foreman_proxy::module { 'pulpcore':
template_path => 'foreman_proxy/plugin/pulpcore.yml.erb',
enabled => $pulpcore_enabled,
Expand All @@ -73,5 +39,11 @@
foreman_proxy::settings_file { 'pulp3': # file removed in rubygem-smart_proxy_pulp 2.0
ensure => absent,
},
foreman_proxy::settings_file { 'pulp': # Pulp 2 support dropped in Katello 4.0
ensure => absent,
},
foreman_proxy::settings_file { 'pulpnode': # Pulp 2 support dropped in Katello 4.0
ensure => absent,
},
]
}
13 changes: 1 addition & 12 deletions manifests/plugin/pulp/params.pp
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
# Default parameters for the Pulp smart proxy plugin
# @api private
class foreman_proxy::plugin::pulp::params {
$enabled = true
$listen_on = 'https'
$version = undef
$pulpnode_enabled = false
$pulpcore_enabled = false
$pulpcore_mirror = false
$pulp_url = "https://${facts['networking']['fqdn']}/pulp"
$pulpcore_api_url = "https://${facts['networking']['fqdn']}"
$pulpcore_content_url = "${pulp_url}/content"
$pulp_dir = '/var/lib/pulp'
$pulp_content_dir = '/var/lib/pulp/content'
$puppet_content_dir = undef
$mongodb_dir = '/var/lib/mongodb'
$pulpcore_content_url = "${pulpcore_api_url}/pulp/content"
}
70 changes: 8 additions & 62 deletions spec/classes/foreman_proxy__plugin__pulp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,15 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_foreman_proxy__plugin('pulp') }

it 'should configure pulp.yml' do
it 'should configure pulpnode.yml' do
is_expected.to contain_file("#{etc_dir}/foreman-proxy/settings.d/pulp.yml")
.with_ensure('file')
.with_owner('root')
.with_group('foreman-proxy')

verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/pulp.yml", [
'---',
':enabled: https',
":pulp_url: https://#{facts[:fqdn]}/pulp",
':pulp_dir: /var/lib/pulp',
':pulp_content_dir: /var/lib/pulp/content',
':puppet_content_dir: /etc/puppetlabs/code/environments',
':mongodb_dir: /var/lib/mongodb'
])
end
.with_ensure('absent')
end

it 'should configure pulpnode.yml' do
is_expected.to contain_file("#{etc_dir}/foreman-proxy/settings.d/pulpnode.yml")
.with_ensure('file')
.with_owner('root')
.with_group('foreman-proxy')

verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/pulpnode.yml", [
'---',
':enabled: false',
":pulp_url: https://#{facts[:fqdn]}/pulp",
':pulp_dir: /var/lib/pulp',
':pulp_content_dir: /var/lib/pulp/content',
':puppet_content_dir: /etc/puppetlabs/code/environments',
':mongodb_dir: /var/lib/mongodb'
])
end
.with_ensure('absent')
end

it 'should configure pulpcore.yml' do
is_expected.to contain_file("#{etc_dir}/foreman-proxy/settings.d/pulpcore.yml")
Expand All @@ -53,7 +29,7 @@

verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/pulpcore.yml", [
'---',
':enabled: false',
':enabled: https',
":pulp_url: https://#{facts[:fqdn]}",
":content_app_url: https://#{facts[:fqdn]}/pulp/content",
':mirror: false'
Expand All @@ -63,52 +39,22 @@
it 'should remove pulp3.yml' do
is_expected.to contain_file("#{etc_dir}/foreman-proxy/settings.d/pulp3.yml")
.with_ensure('absent')
end
end
end

describe 'with overrides' do
let :params do
{
pulpnode_enabled: true,
pulpcore_enabled: true,
pulpcore_mirror: true,
pulpcore_api_url: 'https://pulpcore.example.com',
pulpcore_content_url: 'https://pulpcore.example.com/pulp/content',
pulp_url: 'https://pulp.example.com',
pulp_dir: '/tmp/pulp',
pulp_content_dir: '/tmp/content',
puppet_content_dir: '/tmp/puppet',
mongodb_dir: '/tmp/mongodb',
pulpcore_content_url: 'https://pulpcore.example.com/pulp/content'
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_foreman_proxy__plugin('pulp') }

it 'should configure pulp.yml' do
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/pulp.yml", [
'---',
':enabled: https',
':pulp_url: https://pulp.example.com',
':pulp_dir: /tmp/pulp',
':pulp_content_dir: /tmp/content',
':puppet_content_dir: /tmp/puppet',
':mongodb_dir: /tmp/mongodb'
])
end

it 'should configure pulpnode.yml' do
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/pulpnode.yml", [
'---',
':enabled: https',
':pulp_url: https://pulp.example.com',
':pulp_dir: /tmp/pulp',
':pulp_content_dir: /tmp/content',
':puppet_content_dir: /tmp/puppet',
':mongodb_dir: /tmp/mongodb'
])
end

it 'should configure pulpcore.yml' do
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/pulpcore.yml", [
'---',
Expand Down
6 changes: 0 additions & 6 deletions templates/plugin/pulp.yml.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
---
# Pulp integration
:enabled: <%= @module_enabled %>
:pulp_url: <%= scope.lookupvar("foreman_proxy::plugin::pulp::pulp_url") %>
# Path to pulp, pulp content and mongodb directories
:pulp_dir: <%= scope.lookupvar("foreman_proxy::plugin::pulp::pulp_dir") %>
:pulp_content_dir: <%= scope.lookupvar("foreman_proxy::plugin::pulp::pulp_content_dir") %>
:puppet_content_dir: <%= scope.lookupvar("foreman_proxy::plugin::pulp::real_puppet_content_dir") %>
:mongodb_dir: <%= scope.lookupvar("foreman_proxy::plugin::pulp::mongodb_dir") %>
6 changes: 0 additions & 6 deletions templates/plugin/pulpnode.yml.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
---
# Pulp integration
:enabled: <%= @module_enabled %>
:pulp_url: <%= scope.lookupvar("foreman_proxy::plugin::pulp::pulp_url") %>
# Path to pulp, pulp content and mongodb directories
:pulp_dir: <%= scope.lookupvar("foreman_proxy::plugin::pulp::pulp_dir") %>
:pulp_content_dir: <%= scope.lookupvar("foreman_proxy::plugin::pulp::pulp_content_dir") %>
:puppet_content_dir: <%= scope.lookupvar("foreman_proxy::plugin::pulp::real_puppet_content_dir") %>
:mongodb_dir: <%= scope.lookupvar("foreman_proxy::plugin::pulp::mongodb_dir") %>

0 comments on commit addaa8b

Please sign in to comment.