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
68 changes: 63 additions & 5 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* [`php::repo::debian`](#php--repo--debian): Configure debian apt repo === Parameters [*location*] Location of the apt repository [*repos*] Apt repository names [*include_src*]
* [`php::repo::redhat`](#php--repo--redhat)
* [`php::repo::suse`](#php--repo--suse): Configure suse repo === Parameters [*reponame*] Name of the Zypper repository [*baseurl*] Base URL of the Zypper repository
* [`php::repo::ubuntu`](#php--repo--ubuntu): Configure ubuntu ppa === Parameters [*version*] PHP version to manage (e.g. 5.6)
* [`php::repo::ubuntu`](#php--repo--ubuntu): Configure ubuntu apt repo (packages.sury.org) === Parameters [*location*] Location of the apt repository [*repos*] Apt repository name

### Defined types

Expand Down Expand Up @@ -1834,6 +1834,7 @@ The following parameters are available in the `php::repo::debian` class:
* [`key`](#-php--repo--debian--key)
* [`dotdeb`](#-php--repo--debian--dotdeb)
* [`sury`](#-php--repo--debian--sury)
* [`key_source`](#-php--repo--debian--key_source)

##### <a name="-php--repo--debian--location"></a>`location`

Expand Down Expand Up @@ -1890,6 +1891,14 @@ Data type: `Boolean`

Default value: `true`

##### <a name="-php--repo--debian--key_source"></a>`key_source`

Data type: `String[1]`



Default value: `'https://packages.sury.org/php/apt.gpg'`

### <a name="php--repo--redhat"></a>`php::repo::redhat`

The php::repo::redhat class.
Expand Down Expand Up @@ -1945,26 +1954,75 @@ Default value: `'http://download.opensuse.org/repositories/home:/mayflower:/php5

### <a name="php--repo--ubuntu"></a>`php::repo::ubuntu`

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.

#### Parameters

The following parameters are available in the `php::repo::ubuntu` class:

* [`location`](#-php--repo--ubuntu--location)
* [`repos`](#-php--repo--ubuntu--repos)
* [`include_src`](#-php--repo--ubuntu--include_src)
* [`key_source`](#-php--repo--ubuntu--key_source)
* [`version`](#-php--repo--ubuntu--version)

##### <a name="-php--repo--ubuntu--location"></a>`location`

Data type: `String[1]`



Default value: `'https://packages.sury.org/php/'`

##### <a name="-php--repo--ubuntu--repos"></a>`repos`

Data type: `String[1]`



Default value: `'main'`

##### <a name="-php--repo--ubuntu--include_src"></a>`include_src`

Data type: `Boolean`



Default value: `false`

##### <a name="-php--repo--ubuntu--key_source"></a>`key_source`

Data type: `String[1]`



Default value: `'https://packages.sury.org/php/apt.gpg'`

##### <a name="-php--repo--ubuntu--version"></a>`version`

Data type: `Pattern[/^\d\.\d/]`
Data type: `Optional[String]`



Default value: `'5.6'`
Default value: `undef`

## Defined types

Expand Down
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@

if $manage_repos {
contain php::repo
if $facts['os']['family'] == 'Debian' {
Class['php::repo'] -> Class['apt::update'] -> Class['php::packages']
} else {
Class['php::repo'] -> Class['php::packages']
}
}

class { 'php::packages': }
Expand Down
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