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

Amazon Linux 2 - bugfix - use enterprise linux 7 #95

Merged
merged 4 commits into from
Feb 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
9 changes: 1 addition & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
$epel_gpg_managed = $epel::params::epel_gpg_managed,
$os_maj_release = $epel::params::os_maj_release,
) inherits epel::params {
if "${::osfamily}" == 'RedHat' and "${::operatingsystem}" !~ /Fedora|Amazon/ { # lint:ignore:only_variable_string
Copy link
Member

Choose a reason for hiding this comment

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

The module now explodes if you try to use it on Fedora instead of hitting the notice ("Your operating system ${::operatingsystem} will not have the EPEL repository applied") line.

This is causing build failures in puppet-letsencrypt.

if "${::osfamily}" == 'RedHat' { # lint:ignore:only_variable_string
if $epel_testing_managed {
yumrepo { 'epel-testing':
# lint:ignore:selector_inside_resource
Expand Down Expand Up @@ -229,13 +229,6 @@
}
}

} elsif "${::osfamily}" == 'RedHat' and "${::operatingsystem}" == 'Amazon' { # lint:ignore:only_variable_string
if $epel_managed {
yumrepo { 'epel':
enabled => $epel_enabled,
gpgcheck => $epel_gpgcheck,
}
}
} else {
notice ("Your operating system ${::operatingsystem} will not have the EPEL repository applied")
}
Expand Down
14 changes: 10 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
# the most specific declaration of proxy.
$proxy = 'absent'

if getvar('::operatingsystemmajrelease') {
$os_maj_release = $::operatingsystemmajrelease
if "${::operatingsystem}" == 'Amazon' and "${::operatingsystemmajrelease}" == '2' {
# Amazon Linux 2 is equivalent of Enterprise Linux 7 so we use that version for epel
# https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/
$os_maj_release = '7'
} else {
$os_versions = split("${::operatingsystemrelease}", '[.]') # lint:ignore:only_variable_string
$os_maj_release = $os_versions[0]
if getvar('::operatingsystemmajrelease') {
$os_maj_release = $::operatingsystemmajrelease
} else {
$os_versions = split("${::operatingsystemrelease}", '[.]') # lint:ignore:only_variable_string
$os_maj_release = $os_versions[0]
}
}

if versioncmp($os_maj_release, '5') > 0 {
Expand Down
41 changes: 29 additions & 12 deletions spec/classes/epel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,39 @@
context 'operatingsystem => Amazon' do
let :facts do
default_facts.merge(
operatingsystem: 'Amazon',
operatingsystemrelease: 'Amazon'
operatingsystem: 'Amazon',
operatingsystemrelease: 'Amazon',
operatingsystemmajrelease: '2'
)
end

it { is_expected.not_to contain_yumrepo('epel-testing') }
it { is_expected.not_to contain_yumrepo('epel-testing-debuginfo') }
it { is_expected.not_to contain_yumrepo('epel-testing-source') }
it { is_expected.not_to contain_yumrepo('epel-debuginfo') }
it { is_expected.not_to contain_yumrepo('epel-source') }
it_behaves_like :base_7
it_behaves_like :gpgkey_7
it_behaves_like :epel_source_7
it_behaves_like :epel_debuginfo_7
it_behaves_like :epel_testing_7
it_behaves_like :epel_testing_source_7
it_behaves_like :epel_testing_debuginfo_7

context 'epel_baseurl => https://example.com/epel/7/x86_64' do
let(:params) do
{
epel_baseurl: 'https://example.com/epel/7/x86_64'
}
end

it do
is_expected.to contain_yumrepo('epel').with(
enabled: '1',
gpgcheck: '1'
)
it { is_expected.to contain_yumrepo('epel').with(baseurl: 'https://example.com/epel/7/x86_64') }
it { is_expected.to contain_yumrepo('epel').with(mirrorlist: 'absent') }
end

context 'epel_mirrorlist => absent' do
let(:params) do
{
epel_mirrorlist: 'absent'
}
end

it { is_expected.to contain_yumrepo('epel').with(mirrorlist: 'absent') }
end
end
end