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

Add support for custom repository URL #291

Merged
Merged
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
3 changes: 3 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ grafana::manage_package_repo: true
grafana::package_name: 'grafana'
grafana::package_source: ~
grafana::repo_name: 'stable'
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'
15 changes: 14 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,17 @@
# 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. # lint:ignore:140chars
#
# @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. # lint:ignore:140chars
#
# @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. # lint:ignore:140chars
#
# @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. # lint:ignore:140chars
#
# [*plugins*]
# A hash of plugins to be passed to `create_resources`, wraps around the
# `grafana_plugin` resource.
Expand Down Expand Up @@ -148,7 +157,10 @@
Boolean $manage_package_repo,
String $package_name,
Optional[String] $package_source,
Enum['stable', 'beta'] $repo_name,
Enum['stable', 'beta', 'custom'] $repo_name,
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 All @@ -166,6 +178,7 @@
String[1] $toml_package_name,
String[1] $toml_package_ensure,
Optional[String[1]] $toml_package_provider,
Stdlib::HTTPUrl $repo_gpg_key_url = 'https://packages.grafana.com/gpg.key',
) {
contain grafana::install
contain grafana::config
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