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

WIP: Feature/simon hoenscheid 603 restructure repository management #605

1 change: 1 addition & 0 deletions data/CentOS/6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/CentOS/7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/CentOS/8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
25 changes: 25 additions & 0 deletions data/Debian/10.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +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'
1 change: 1 addition & 0 deletions data/Debian/9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/Fedora/31.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/Fedora/32.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/Fedora/33.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/FreeBSD/11.3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/FreeBSD/11.4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/FreeBSD/12.1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/OpenSuSE/15.1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/OpenSuSE/15.2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/OpenSuSE/15.3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/RedHat/6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/RedHat/7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/RedHat/8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/SLES/11.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/SLES/12.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/SLES/15.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/Ubuntu/16.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/Ubuntu/18.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions data/Ubuntu/20.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
2 changes: 0 additions & 2 deletions data/default.yaml → data/common.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---

lookup_options:
php::fpm::pools:
merge: first

10 changes: 8 additions & 2 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
version: 5
defaults:
datadir: 'data'
data_hash: 'yaml_data'

hierarchy:
- name: default.yaml
- name: 'My Hierachie'
SimonHoenscheid marked this conversation as resolved.
Show resolved Hide resolved
paths:
- 'default.yaml'
- '%{facts.os.name}/%{facts.os.release.full}.yaml'
- '%{facts.os.name}/%{facts.os.release.major}.yaml'
- 'common.yaml'
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 = {},
Copy link
Member

Choose a reason for hiding this comment

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

  • should maybe "custom repo detail" or "repo config" or "repo settings" or simply "repository" (is it real relevant if it is a external or internal repository? isn't it "here we have custom repository config" (i can be the default debian repo where i only change a key hash)

  • should be a custom type like

type Profile::Apt::Source = Struct[{
    Optional[location] =>     Optional[String[1]],
    Optional[comment] =>      String[1],
    Optional[ensure] =>       Optional[Enum['file', 'present', 'absent']],
    Optional[release] =>      Optional[String],
    Optional[repos] =>        String[1],
    Optional[include] =>      Optional[Struct[{
                                Optional[src] => Boolean,
                                Optional[deb] => Boolean,
                              }]],
    Optional[key] =>          Optional[Struct[{
                                Optional[id] => String[1],
                                Optional[source] => String[1],
                              }]],
    Optional[pin] =>          Optional[Struct[{
                                Optional[explanation] => String[1],
                                Optional[packages] => String[1],
                                Optional[origin] => String[1],
                                Optional[priority] => Integer,
                              }]],
    Optional[architecture] =>     Optional[String],
    Optional[allow_unsigned] =>     Boolean,
    Optional[notify_update] =>     Boolean,

    # Optional[comment]  => String[1],
    # location => 'https://packages.gitlab.com/runner/gitlab-runner/debian/',
    # release  => 'stretch',
    # repos    => 'main',
    # pin => {
    #   explanation => 'Prefer GitLab provided packages over the Debian native ones',
    #   packages => 'gitlab-runner',
    #   origin => 'packages.gitlab.com',
    #   priority => 1001,},
    # key      => {
    #   'id'  => '1A4C919DB987D435939638B914219A96E15E78F4',
    #   'source' => 'https://packages.gitlab.com/runner/gitlab-runner/gpgkey',
    # },
    # include  => {
    #   'src' => true,
    #   'deb' => true,
    # },
}]

Copy link
Member Author

Choose a reason for hiding this comment

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

does this work for every repo type?

Copy link
Member

Choose a reason for hiding this comment

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

"yes" we would have to write a type for each repo stucture we want to support.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add this type to the module


) 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' }
SimonHoenscheid marked this conversation as resolved.
Show resolved Hide resolved
'Debian', 'Ubuntu': { contain '::php::repo::debian' }
SimonHoenscheid marked this conversation as resolved.
Show resolved Hide resolved
default: { contain '::php::repo::fallback' }
SimonHoenscheid marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
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,
SimonHoenscheid marked this conversation as resolved.
Show resolved Hide resolved
) {
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,
}
}
}
7 changes: 7 additions & 0 deletions manifests/repo/fallback.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# the fallback class, throws an error, if called
SimonHoenscheid marked this conversation as resolved.
Show resolved Hide resolved
class php::repo::fallback () {
assert_private()

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