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

Add Pulpcore repository class #123

Merged
merged 1 commit into from
Oct 6, 2020
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
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_tag' => "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),
notify => Anchor['pulpcore::repo'],
}

# An anchor is used because it can be collected
anchor { 'pulpcore::repo': } # lint:ignore:anchor_resource
}
10 changes: 10 additions & 0 deletions spec/classes/pulpcore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@
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_class('pulpcore::repo')
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
17 changes: 17 additions & 0 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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_anchor('pulpcore::repo')
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'),
Copy link
Member Author

Choose a reason for hiding this comment

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

Once voxpupuli/voxpupuli-acceptance#13 is merged and released in the gem, you can use BEAKER_FACTER_PULPCORE_VERSION=3.7 when running beaker to test out version 3.7. If it's undefined, it falls back to the class default (3.6).

}

# 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_tag | -%>
[pulpcore]
name=Pulpcore <%= $version %>
baseurl=https://yum.theforeman.org/pulpcore/<%= $version %>/<%= $dist_tag %>/$basearch
enabled=1
gpgcheck=1
gpgkey=https://yum.theforeman.org/pulpcore/<%= $version %>/GPG-RPM-KEY-pulpcore
module_hotfixes=1

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