Skip to content

Commit

Permalink
Add Pulpcore repository class
Browse files Browse the repository at this point in the history
This class uses the new yum.theforeman.org repos that are versions per
Pulpcore release. This allows easy switching between versions. It also
properly sets the GPG key validation.

It does switch acceptance testing from staging repositories to stable
repositories. Another implication is that it switches to Pulpcore 3.6 by
default. This was chosen since 3.7 is not complete yet.
  • Loading branch information
ekohl committed Oct 6, 2020
1 parent b3b7c13 commit b334833
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 15 deletions.
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
contain pulpcore::service
contain pulpcore::apache

Anchor <| title == 'pulpcore::repo' |> ~> Class['pulpcore::install']
Class['pulpcore::install'] ~> Class['pulpcore::config', 'pulpcore::database', 'pulpcore::service']
Class['pulpcore::config'] ~> Class['pulpcore::database', 'pulpcore::static', 'pulpcore::service']
Class['pulpcore::database', 'pulpcore::static'] -> Class['pulpcore::service'] -> Class['pulpcore::apache']
Expand Down
24 changes: 24 additions & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Configure the Pulpcore repo
#
# @param version
# The Pulpcore version to use
class pulpcore::repo (
Pattern['^\d+\.\d+$'] $version = '3.6',
) {
$context = {
'version' => $version,
'dist_code' => "el${facts['os']['release']['major']}",
}

file { '/etc/yum.repos.d/pulpcore.repo':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => epp('pulpcore/repo.epp', $context),
before => Anchor['pulpcore::repo'],
}

# An anchor is used because it can be collected
anchor { 'pulpcore::repo': } # lint:ignore:anchor_resource
}
9 changes: 9 additions & 0 deletions spec/classes/pulpcore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@
end
end

context 'with the repo' do
let(:pre_condition) { 'include pulpcore::repo' }

it do
is_expected.to compile.with_all_deps
is_expected.to contain_file('/etc/yum.repos.d/pulpcore.repo').that_notifies('Class[pulpcore::install]')
end
end

context 'with custom ports' do
let :params do
{
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper'

describe 'pulpcore::repo' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_file('/etc/yum.repos.d/pulpcore.repo')
.with_content(%r{^baseurl=https://yum.theforeman.org/pulpcore/\d+\.\d+/el\d+/\$basearch$})
.that_comes_before('Anchor[pulpcore::repo]')
end
end
end
end
18 changes: 3 additions & 15 deletions spec/setup_acceptance_node.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,14 @@
default: {}
}

# Defaults to staging, for release, use
# $baseurl = "https://fedorapeople.org/groups/katello/releases/yum/nightly/pulpcore/el${major}/x86_64/"
$baseurl = "http://koji.katello.org/releases/yum/katello-nightly/pulpcore/el${major}/x86_64/"

$pulpcore_repo_conf = @("CONF")
[pulpcore]
baseurl=${baseurl}
gpgcheck=0
module_hotfixes=1
CONF

file { '/etc/yum.repos.d/pulpcore.repo':
ensure => file,
content => $pulpcore_repo_conf,
class { 'pulpcore::repo':
version => fact('pulpcore_version'),
}

# Needed as a workaround for idempotency
if $facts['os']['selinux']['enabled'] {
package { 'pulpcore-selinux':
ensure => installed,
require => File['/etc/yum.repos.d/pulpcore.repo'],
require => Class['pulpcore::repo'],
}
}
16 changes: 16 additions & 0 deletions templates/repo.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%- | String[1] $version, String[1] $dist_code | -%>
[pulpcore]
name=Pulpcore <%= $version %>
baseurl=https://yum.theforeman.org/pulpcore/<%= $version %>/<%= $dist_code %>/$basearch
enabled=1
gpgcheck=1
gpgkey=https://yum.theforeman.org/pulpcore/<%= $version %>/GPG-RPM-KEY-pulpcore
module_hotfixes=1

[pulpcore-source]
name=Pulpcore ${version} Soure
baseurl=https://yum.theforeman.org/pulpcore/<%= $version %>/<%= $dist_code %>/source
enabled=0
gpgcheck=1
gpgkey=https://yum.theforeman.org/pulpcore/<%= $version %>/GPG-RPM-KEY-pulpcore
module_hotfixes=1

0 comments on commit b334833

Please sign in to comment.