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

Support other versions of remi repo on redhat #669

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions manifests/repo/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/(?i:Amazon)/ => '6',
default => '$releasever', # Yum var
}
$version = $yum_repo.match('.\d$')[0]
Copy link
Member

Choose a reason for hiding this comment

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

.\d$ feels weird: any char followed by a digit at the end of a line.

I guess what you mean here is any number of digits at the end of the string? \d+\z


yumrepo { 'remi':
descr => 'Remi\'s RPM repository for Enterprise Linux $releasever - $basearch',
Expand All @@ -23,9 +24,9 @@
priority => 1,
}

yumrepo { 'remi-php56':
descr => 'Remi\'s PHP 5.6 RPM repository for Enterprise Linux $releasever - $basearch',
mirrorlist => "https://rpms.remirepo.net/enterprise/${releasever}/php56/mirror",
yumrepo { "remi-php${version}":
descr => "Remi's PHP ${version} RPM repository for Enterprise Linux \$releasever - \$basearch",
mirrorlist => "https://rpms.remirepo.net/enterprise/${releasever}/php${version}/mirror",
enabled => 1,
gpgcheck => 1,
gpgkey => 'https://rpms.remirepo.net/RPM-GPG-KEY-remi',
Expand Down
33 changes: 33 additions & 0 deletions spec/acceptance/repo/php_repo_redhat_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'with RedHat', if: (fact('os.family') == 'RedHat') do
context 'default parameters' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
include 'php::repo::redhat'
PUPPET
end
end
describe yumrepo('remi-php56') do
it { is_expected.to exist }
end
end

context 'with version 7.2' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'php::repo::redhat':
yum_repo => 'remi_php72',
}
PUPPET
end
end
describe yumrepo('remi-php72') do
it { is_expected.to exist }
end
end
end
51 changes: 51 additions & 0 deletions spec/classes/php_repo_redhat_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'php::repo::redhat', type: :class do
on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end

case facts[:osfamily]
when 'RedHat'
describe 'when called with no parameters on RedHat' do
it { is_expected.to contain_yumrepo('remi-php56') }
end

describe 'when called with version 7.0 on RedHat' do
let(:params) do
{
yum_repo: 'remi_php70'
}
end

it { is_expected.to contain_yumrepo('remi-php70') }
end

describe 'when call with version 7.1 on RedHat' do
let(:params) do
{
yum_repo: 'remi_php71'
}
end

it { is_expected.to contain_yumrepo('remi-php71') }
end

describe 'when call with version 7.2 on RedHat' do
let(:params) do
{
yum_repo: 'remi_php72'
}
end

it { is_expected.to contain_yumrepo('remi-php72') }
end

end
end
end
end