Skip to content
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
11 changes: 7 additions & 4 deletions manifests/repo/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
Boolean $dotdeb = true,
Boolean $sury = true,
String[1] $key_source = 'https://packages.sury.org/php/apt.gpg',
) {
assert_private()

Expand All @@ -51,17 +52,19 @@
}

if ($sury and versioncmp($facts['os']['release']['major'], '9') >= 0) {
apt::keyring { 'packages-sury-org.gpg':
source => $key_source,
}

apt::source { 'source_php_sury':
location => 'https://packages.sury.org/php/',
repos => 'main',
include => {
'src' => $include_src,
'deb' => true,
},
key => {
name => 'php-sury.gpg',
source => 'https://packages.sury.org/php/apt.gpg',
},
keyring => '/etc/apt/keyrings/packages-sury-org.gpg',
require => Apt::Keyring['packages-sury-org.gpg'],
}
}
}
46 changes: 35 additions & 11 deletions manifests/repo/ubuntu.pp
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
# Configure ubuntu ppa
# Configure ubuntu apt repo (packages.sury.org)
#
# === Parameters
#
# [*location*]
# Location of the apt repository
#
# [*repos*]
# Apt repository names
#
# [*include_src*]
# Add source repository
#
# [*key_source*]
# URL of the GPG key file
#
# [*version*]
# PHP version to manage (e.g. 5.6)
# Removed. PHP version selection via PPA is no longer supported.
# All PHP versions are available from a single repository.
#
class php::repo::ubuntu (
Pattern[/^\d\.\d/] $version = '5.6',
String[1] $location = 'https://packages.sury.org/php/',
String[1] $repos = 'main',
Boolean $include_src = false,
String[1] $key_source = 'https://packages.sury.org/php/apt.gpg',
Optional[String] $version = undef,
) {
if $facts['os']['name'] != 'Ubuntu' {
fail("class php::repo::ubuntu does not work on OS ${facts['os']['name']}")
}
include 'apt'

if ($version == '5.5') {
fail('PHP 5.5 is no longer available for download')
if $version != undef {
fail('php::repo::ubuntu: the $version parameter has been removed. packages.sury.org provides all PHP versions in a single repository.')
}

$version_repo = $version ? {
'5.4' => 'ondrej/php5-oldstable',
default => 'ondrej/php'
include 'apt'

apt::keyring { 'packages-sury-org.gpg':
source => $key_source,
}

::apt::ppa { "ppa:${version_repo}":
package_manage => true,
apt::source { 'source_php_sury':
location => $location,
repos => $repos,
include => {
'src' => $include_src,
'deb' => true,
},
keyring => '/etc/apt/keyrings/packages-sury-org.gpg',
require => Apt::Keyring['packages-sury-org.gpg'],
}
}
2 changes: 2 additions & 0 deletions spec/classes/php_repo_debian_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
if facts[:os]['release']['major'].to_i < 9
it { is_expected.to contain_apt__source('source_php_dotdeb') }
it { is_expected.not_to contain_apt__source('source_php_sury') }
it { is_expected.not_to contain_apt__keyring('packages-sury-org.gpg') }
elsif facts[:os]['release']['major'].to_i >= 9
it { is_expected.not_to contain_apt__source('source_php_dotdeb') }
it { is_expected.to contain_apt__source('source_php_sury') }
it { is_expected.to contain_apt__keyring('packages-sury-org.gpg') }
end
else
it { is_expected.to compile.and_raise_error(%r{class php::repo::debian does not work on OS}) }
Expand Down
11 changes: 10 additions & 1 deletion spec/classes/php_repo_ubuntu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@
describe 'works without params' do
if facts[:os]['name'] == 'Ubuntu'
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_apt__ppa('ppa:ondrej/php') }
it { is_expected.to contain_apt__keyring('packages-sury-org.gpg') }
it { is_expected.to contain_apt__source('source_php_sury') }
else
it { is_expected.to compile.and_raise_error(%r{class php::repo::ubuntu does not work on OS}) }
end
end

describe 'fails when version is specified' do
if facts[:os]['name'] == 'Ubuntu'
let(:params) { { version: '8.1' } }

it { is_expected.to compile.and_raise_error(%r{version parameter has been removed}) }
end
end
end
end
end
Loading