Skip to content

Commit

Permalink
exemple repo handling for debian 10
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHoenscheid committed Sep 27, 2020
1 parent 6eeb0b0 commit fcf3f4c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 83 deletions.
26 changes: 25 additions & 1 deletion data/Debian/10.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
---
---
php::external_repo: false
php::php_version: '7.3'
php::os_supported_php_versions:
- '7.3'

php::external_repo_supported_php_versions:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'

php::external_repo_details:
'source_php_sury':
comment: 'the debian sury repo sury.org'
location: 'https://packages.sury.org/php/'
repos: 'main'
include:
src: true
deb: true
key:
id: '15058500A0235D97F5D10063B188E2B695BD4743'
source: 'https://packages.sury.org/php/apt.gpg'
7 changes: 7 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@
String $log_group = $php::params::fpm_group,
Boolean $pool_purge = $php::params::pool_purge,
Boolean $reload_fpm_on_config_changes = true,
# added for refactoring
Boolean $external_repo = false,
Optional[String[1]] $php_version = undef,
Optional[Array] $os_supported_php_versions = undef,
Optional[Array] $external_repo_supported_php_versions = undef,
Hash $external_repo_details = {},

) inherits php::params {
$real_fpm_package = pick($fpm_package, "${package_prefix}${php::params::fpm_package_suffix}")

Expand Down
39 changes: 11 additions & 28 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
# Configure package repository
#
class php::repo {
$msg_no_repo = "No repo available for ${facts['os']['family']}/${facts['os']['name']}"

case $facts['os']['family'] {
'Debian': {
# no contain here because apt does that already
case $facts['os']['name'] {
'Debian': {
include php::repo::debian
}
'Ubuntu': {
include php::repo::ubuntu
}
default: {
fail($msg_no_repo)
}
}
}
'FreeBSD': {}
'Suse': {
contain php::repo::suse
}
'RedHat': {
contain 'php::repo::redhat'
}
default: {
fail($msg_no_repo)
}
class php::repo (
Boolean $external_repo = $php::external_repo,
Optional[String[1]] $php_version = $php::php_version,
Optional[Array] $external_repo_supported_php_versions = $php::external_repo_supported_php_versions,
) {
if ($external_repo and $php_version in $external_repo_supported_php_versions) {
case $facts['os']['name'] {
'RedHat', 'CentOS': { contain '::php::repo::redhat' }
'Debian', 'Ubuntu': { contain '::php::repo::debian' }
default: { contain '::php::repo::fallback' }
}
}
}
60 changes: 6 additions & 54 deletions manifests/repo/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,18 @@
#
# === Parameters
#
# [*location*]
# Location of the apt repository
#
# [*release*]
# Release of the apt repository
#
# [*repos*]
# Apt repository names
#
# [*include_src*]
# Add source source repository
#
# [*key*]
# Public key in apt::key format
#
# [*dotdeb*]
# Enable special dotdeb handling
#
# [*sury*]
# Enable special sury handling
# [*external_repo_details*]
# The repository details
#
class php::repo::debian (
$location = 'https://packages.dotdeb.org',
$release = 'wheezy-php56',
$repos = 'all',
$include_src = false,
$key = {
'id' => '6572BBEF1B5FF28B28B706837E3F070089DF5277',
'source' => 'http://www.dotdeb.org/dotdeb.gpg',
},
$dotdeb = true,
$sury = true,
Hash $external_repo_details = $php::external_repo_details,
) {
assert_private()

include 'apt'

apt::source { "source_php_${release}":
location => $location,
release => $release,
repos => $repos,
include => {
'src' => $include_src,
'deb' => true,
},
key => $key,
}

if ($sury and $php::globals::php_version in ['7.1','7.2']) {
apt::source { 'source_php_sury':
location => 'https://packages.sury.org/php/',
repos => 'main',
include => {
'src' => $include_src,
'deb' => true,
},
key => {
id => '15058500A0235D97F5D10063B188E2B695BD4743',
source => 'https://packages.sury.org/php/apt.gpg',
},
$external_repo_details.each |String $repository, Hash $repository_details| {
apt::source { $repository:
* => $repository_details,
}
}
}
6 changes: 6 additions & 0 deletions manifests/repo/fallback.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class php::repo::fallback () {
assert_private()

$msg_no_repo = "No repo available for ${facts['os']['family']}/${facts['os']['name']}"
fail($msg_no_repo)
}

0 comments on commit fcf3f4c

Please sign in to comment.