Skip to content

Commit

Permalink
Add support for custom repository URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Hoenscheid committed Aug 12, 2022
1 parent 746f5b6 commit cfc8e71
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
4 changes: 4 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ grafana::manage_package_repo: true
grafana::package_name: 'grafana'
grafana::package_source: ~
grafana::repo_name: 'stable'
grafana::repo_gpg_key_url: 'https://packages.grafana.com/gpg.key'
grafana::repo_key_id: ~
grafana::repo_release: ~
grafana::repo_url: ~
grafana::rpm_iteration: '1'
grafana::service_name: 'grafana-server'
grafana::version: 'installed'
Expand Down
2 changes: 2 additions & 0 deletions data/family/Debian.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
grafana::install_method: 'repo'
grafana::repo_url: 'https://packages.grafana.com/oss/deb'
grafana::repo_key_id: '4E40DDF6D76E284A4A6780E48C8C34C524098CB6'
grafana::sysconfig_location: '/etc/default/grafana-server'
1 change: 1 addition & 0 deletions data/family/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
grafana::install_method: 'repo'
grafana::repo_url: 'https://packages.grafana.com/oss/rpm'
grafana::sysconfig_location: '/etc/sysconfig/grafana-server'
24 changes: 23 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,26 @@
# When using 'repo' install_method, the repo to look for packages in.
# Set to 'stable' to install only stable versions
# Set to 'beta' to install beta versions
# Set to 'custom' to install from custom repo. Use full URL
# Defaults to stable.
#
# [*repo_gpg_key_url*]
# When using 'repo' install_method, the repo_gpg_key_url to look for the gpg signing key of the repo.
# Defaults to https://packages.grafana.com/gpg.key.
#
# [*repo_key_id*]
# When using 'repo' install_method, the repo_key_id of the repo_gpg_key_url key on Debian based systems.
# Defaults to 4E40DDF6D76E284A4A6780E48C8C34C524098CB6.
#
# [*repo_release*]
# Optional value, needed on Debian based systems, if repo name is set to custom, used to identify the release of the repo.
# No default value.
#
# [*repo_url*]
# When using 'repo' install_method, the repo_url to look for packages in.
# Set to a custom string value to install from a custom repo.
# Defaults to https://packages.grafana.com/oss/OS_SPECIFIC_SLUG_HERE.
#
# [*plugins*]
# A hash of plugins to be passed to `create_resources`, wraps around the
# `grafana_plugin` resource.
Expand Down Expand Up @@ -148,7 +166,11 @@
Boolean $manage_package_repo,
String $package_name,
Optional[String] $package_source,
Enum['stable', 'beta'] $repo_name,
Enum['stable', 'beta', 'custom'] $repo_name,
Stdlib::HTTPUrl $repo_gpg_key_url,
Optional[String[1]] $repo_key_id,
Optional[String[1]] $repo_release,
Optional[Stdlib::HTTPUrl] $repo_url,
String $rpm_iteration,
String $service_name,
String $version,
Expand Down
20 changes: 13 additions & 7 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,20 @@
if !defined(Class['apt']) {
include apt
}

$real_repo_release = $grafana::repo_name ? {
/(stable|beta)/ => $grafana::repo_name,
'custom' => $grafana::repo_release,
}

apt::source { 'grafana':
location => 'https://packages.grafana.com/oss/deb',
release => $grafana::repo_name,
location => $grafana::repo_url,
release => $real_repo_release,
architecture => 'amd64,arm64,armhf',
repos => 'main',
key => {
'id' => '4E40DDF6D76E284A4A6780E48C8C34C524098CB6',
'source' => 'https://packages.grafana.com/gpg.key',
'id' => $grafana::repo_key_id,
'source' => $grafana::repo_gpg_key_url,
},
before => Package['grafana'],
}
Expand All @@ -115,8 +121,8 @@
if ( $grafana::manage_package_repo ) {
# http://docs.grafana.org/installation/rpm/#install-via-yum-repository
$baseurl = $grafana::repo_name ? {
'stable' => 'https://packages.grafana.com/oss/rpm',
'beta' => 'https://packages.grafana.com/oss/rpm-beta',
/(stable|custom)/ => $grafana::repo_url,
'beta' => "${grafana::repo_url}-${grafana::repo_name}",
}

yumrepo { 'grafana':
Expand All @@ -128,7 +134,7 @@
descr => "grafana-${grafana::repo_name} repo",
baseurl => $baseurl,
gpgcheck => 1,
gpgkey => 'https://packages.grafana.com/gpg.key',
gpgkey => $grafana::repo_gpg_key_url,
enabled => 1,
before => Package['grafana'],
}
Expand Down

0 comments on commit cfc8e71

Please sign in to comment.