Skip to content

Commit

Permalink
Make tar download path configurable to support local sources.
Browse files Browse the repository at this point in the history
Simple approach to solve garethr#13. RPM/DEB-based approach is more
difficult as paths differ between archive and packages.
  • Loading branch information
Florian Thiel committed Nov 16, 2014
1 parent f144d0e commit e7fd609
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ configuration file.
In this last case you're responsible for making sure that file exists,
via another puppet resource or otherwise.

By default, the riemann archive is downloaded from aphyr.com. If you
want to supply your own download location, set it as follows:

class { 'riemann': archive_download_base_path => 'http://some.domain/path' }

Note that the archive has be called `riemann-${version}.tar.bz2` and
has to have the same structure as the one provided by aphyr.com.

## Example

For a fully working example of this module you may also be interested in
Expand Down
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@
# The system user which riemann runs as. Defaults to riemann. Will be
# created by the module.
#
# [*archive_dowload_base_path*]
# The base path (URL) where the riemann tar.bz2 file resides. Defaults
# to the primary distribution location on aphyr.com

class riemann(
$version = $riemann::params::version,
$config_file = $riemann::params::config_file,
$host = $riemann::params::host,
$port = $riemann::params::port,
$user = $riemann::params::user,
$archive_download_base_path = $riemann::params::archive_download_base_path,
) inherits riemann::params {

validate_absolute_path($config_file)
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}

wget::fetch { 'download_riemann':
source => "http://aphyr.com/riemann/riemann-${riemann::version}.tar.bz2",
source => "${riemann::archive_download_base_path}/riemann-${riemann::version}.tar.bz2",
destination => "/usr/local/src/riemann-${riemann::version}.tar.bz2",
before => Exec['untar_riemann'],
}
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
$host = 'localhost'
$user = 'riemann'
$rvm_ruby_string = undef
$archive_download_base_path = 'http://aphyr.com/riemann'

case $::osfamily {
'Debian': {
Expand Down
15 changes: 15 additions & 0 deletions spec/classes/riemann/riemann_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@
it { should contain_file('/etc/puppet/riemann.yaml').with_content(/6000/)}
end

context 'without a custom tar download path' do
let(:params) { {'version' => '1.0.0'} }
it 'should download the riemann archive from default location' do
should contain_wget__fetch('download_riemann').with_source('http://aphyr.com/riemann/riemann-1.0.0.tar.bz2')
end
end

context 'with a custom tar download path' do
let(:params) { {'archive_download_base_path' => 'https://custom.domain/custom_path',
'version' => '1.0.0'} }
it 'should download the riemann archive from the custom location' do
should contain_wget__fetch('download_riemann').with_source('https://custom.domain/custom_path/riemann-1.0.0.tar.bz2')
end
end

context 'with an invalid config file path' do
let(:params) { {'config_file' => 'not a path'} }
it do
Expand Down

0 comments on commit e7fd609

Please sign in to comment.