The default value for graylogcollectorsidecar::version
is "latest". Unfortunately, this causes puppet to fail with the message:
Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Can not find a valid download URL for the release. at <...>/githubreleases/manifests/download.pp:69:17 at <...>/graylogcollectorsidecar/manifests/dist/redhat.pp:24 on node <...>
Locating the error, took a little dive into the code:
Including graylogcollectorsidecar
with graylogcollectorsidecar::version: 'latest'
(api_url
and tags
are set to meaningful values) instantiates the class graylogcollectorsidecar
with the parameters
$api_url,
$tags,
$update_interval = undef,
$tls_skip_verify = undef,
$send_status = undef,
$list_log_files = undef,
$node_id = undef,
$collector_id = undef,
$log_path = undef,
$log_rotation_time = undef,
$log_max_age = undef,
$backends = undef,
$version = 'latest'
) {…}
which uses on RedHat systems the class graylogcollectorsidecar::dist::redhat
(arguments replaced for better traceability)
'RedHat': {
class {
'graylogcollectorsidecar::dist::redhat':
version => ‘latest’,
api_url => $api_url,
tags => $tags,
update_interval => undef,
tls_skip_verify => undef,
send_status => undef,
list_log_files => undef,
node_id => undef,
collector_id => undef,
log_path => undef,
log_rotation_time => undef,
log_max_age => undef,
backends => undef
}
}
In dist/redhat.pp
this brings us to
githubreleases::download {
'get_sidecar_package':
author => 'Graylog2',
repository => 'collector-sidecar',
release => ‘latest’,
is_tag => true,
asset => true,
asset_filepattern => "${::architecture}\\.rpm",
target => '/tmp/collector-sidecar.rpm'
}
The hardcoded value is_tag => true,
will become important later. For the class githubreleases::download
this means an instantiation with the parameter
$author = 'Graylog2',
$repository = 'collector-sidecar',
$release = ‘latest’,
$asset = true,
$use_zip = undef,
$asset_filepattern = "${::architecture}\\.rpm",
$asset_contenttype = undef,
$asset_fallback = undef,
$is_tag = true,
$use_auth = undef,
$username = undef,
$password = undef,
$target = '/tmp/collector-sidecar.rpm'
The class itself calls the ruby lib github_release
to generate the download URL (as usual, all parameters are already replaced)
$source_url = github_release({
author => 'Graylog2',
repository => ‘collector-sidecar',
release => ‘latest’,
asset => true,
use_zip => undef,
asset_filepattern => "${::architecture}\\.rpm",
asset_contenttype => undef,
asset_fallback => undef,
is_tag => true,
use_auth => undef,
username => undef,
password => undef
})
Taking a look into lib/puppet/parser/functions/github_release.rb
brings us to the lines (keep the hardcoded /releases
in the sprint function in mind):
tag_part = ''
if arguments[:is_tag]
tag_part = 'tags/'
end
url = sprintf(
'%s/%s/%s/releases/%s%s',
'https://api.github.com/repos',
arguments[:author],
arguments[:repository],
tag_part,
arguments[:release]
)
Since is_tag
is true, tag_part
is set to 'tags/‘
so that URL is returned as the result of
sprintf(
'%s/%s/%s/releases/%s%s',
'https://api.github.com/repos',
‘Graylog2’,
‘collector-sidecar',
'tags/',
‘latest’
)
Which is "https://api.github.com/repos/Graylog2/collector-sidecar/releases/tags/latest
" and does not exist:
{ "message": "Not Found", "documentation_url": "https://developer.github.com/v3" }
What worked for me was:
- latest release ->
https://api.github.com/repos/Graylog2/collector-sidecar/releases/latest
- specific release ->
https://api.github.com/repos/Graylog2/collector-sidecar/releases/tags/0.1.4
That means, if a release is specified, then is_tag
has to be set to true
. If “latest” is selected, then is_tag
has to be false
. Sadly, the value of is_tag
is hardcoded and can not be configured, so that the only workaround for me currently is to specify a version instead of choosing “latest”.
(a pull request with a bug fix to this issue will follow)