Skip to content

Commit

Permalink
Merge pull request #23 from dhoppe/archive
Browse files Browse the repository at this point in the history
Migrate to archive module
  • Loading branch information
bastelfreak authored Mar 26, 2017
2 parents f31a445 + f59f529 commit 0508940
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fixtures:
repositories:
archive: "https://github.com/voxpupuli/puppet-archive"
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib"
staging: "https://github.com/voxpupuli/puppet-staging"
symlinks:
"prometheus": "#{source_dir}"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ On the server (for prometheus version >= 1.0.0):
class { 'prometheus':
version => '1.0.0',
scrape_configs => [ {'job_name'=>'prometheus','scrape_interval'=> '30s','scrape_timeout'=>'30s','static_configs'=> [{'targets'=>['localhost:9090'], 'labels'=> { 'alias'=>'Prometheus'}}]}],
extra_options => '-alertmanager.url http://localhost:9093 -web.console.templates=/opt/staging/prometheus-1.0.0.linux-amd64/consoles -web.console.libraries=/opt/staging/prometheus-1.0.0.linux-amd64/console_libraries',
extra_options => '-alertmanager.url http://localhost:9093 -web.console.templates=/opt/prometheus-1.0.0.linux-amd64/consoles -web.console.libraries=/opt/prometheus-1.0.0.linux-amd64/console_libraries',
localstorage => '/prometheus/prometheus',
}
```
Expand Down
21 changes: 10 additions & 11 deletions manifests/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,24 @@

case $install_method {
'url': {
include ::staging
$staging_file = "${name}-${version}.${download_extension}"
$binary = "${::staging::path}/${name}-${version}.${os}-${arch}/${name}"
staging::file { $staging_file:
source => $real_download_url,
archive { "/tmp/${name}-${version}.${download_extension}":
ensure => present,
extract => true,
extract_path => '/opt',
source => $real_download_url,
checksum_verify => false,
creates => "/opt/${name}-${version}.${os}-${arch}/${name}",
cleanup => true,
} ->
staging::extract { $staging_file:
target => $::staging::path,
creates => $binary,
} ->
file { $binary:
file { "/opt/${name}-${version}.${os}-${arch}/${name}":
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555',
} ->
file { "${bin_dir}/${name}":
ensure => link,
notify => $notify_service,
target => $binary,
target => "/opt/${name}-${version}.${os}-${arch}/${name}",
}
}
'package': {
Expand Down
26 changes: 12 additions & 14 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,24 @@
}
case $::prometheus::install_method {
'url': {
include ::staging
staging::file { "prometheus-${prometheus::version}.${prometheus::download_extension}":
source => $prometheus::real_download_url,
} ->
file { "${::staging::path}/prometheus-${prometheus::version}":
ensure => directory,
} ->
staging::extract { "prometheus-${prometheus::version}.${prometheus::download_extension}":
target => $::staging::path,
creates => "${::staging::path}/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/prometheus",
archive { "/tmp/prometheus-${prometheus::version}.${prometheus::download_extension}":
ensure => present,
extract => true,
extract_path => '/opt',
source => $prometheus::real_download_url,
checksum_verify => false,
creates => "/opt/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/prometheus",
cleanup => true,
} ->
file {
"${::staging::path}/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/prometheus":
"/opt/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/prometheus":
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555';
"${::prometheus::bin_dir}/prometheus":
ensure => link,
notify => $::prometheus::notify_service,
target => "${::staging::path}/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/prometheus";
target => "/opt/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/prometheus";
$::prometheus::shared_dir:
ensure => directory,
owner => $::prometheus::user,
Expand All @@ -43,11 +41,11 @@
"${::prometheus::shared_dir}/consoles":
ensure => link,
notify => $::prometheus::notify_service,
target => "${::staging::path}/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/consoles";
target => "/opt/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/consoles";
"${::prometheus::shared_dir}/console_libraries":
ensure => link,
notify => $::prometheus::notify_service,
target => "${::staging::path}/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/console_libraries";
target => "/opt/prometheus-${prometheus::version}.${prometheus::os}-${prometheus::arch}/console_libraries";
}
}
'package': {
Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"issue_url": "https://github.com/voxpupuli/puppet-prometheus/issues",
"dependencies": [
{
"name":"puppet/staging",
"version_requirement":">=1.0.7 <3.0.0"
"name":"puppet/archive",
"version_requirement":">=1.3.0 <2.0.0"
},
{
"name":"puppetlabs/stdlib",
Expand Down
6 changes: 2 additions & 4 deletions spec/classes/haproxy_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge(
staging_http_get: 'curl'
)
facts
end

context 'with version specified' do
Expand All @@ -18,7 +16,7 @@
}
end
describe 'install correct binary' do
it { is_expected.to contain_file('/usr/local/bin/haproxy_exporter').with('target' => '/opt/staging/haproxy_exporter-0.7.1.linux-amd64/haproxy_exporter') }
it { is_expected.to contain_file('/usr/local/bin/haproxy_exporter').with('target' => '/opt/haproxy_exporter-0.7.1.linux-amd64/haproxy_exporter') }
end
end
end
Expand Down
6 changes: 2 additions & 4 deletions spec/classes/node_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge(
staging_http_get: 'curl'
)
facts
end

context 'with version specified' do
Expand All @@ -18,7 +16,7 @@
}
end
describe 'install correct binary' do
it { is_expected.to contain_file('/usr/local/bin/node_exporter').with('target' => '/opt/staging/node_exporter-0.13.0.linux-amd64/node_exporter') }
it { is_expected.to contain_file('/usr/local/bin/node_exporter').with('target' => '/opt/node_exporter-0.13.0.linux-amd64/node_exporter') }
end
end
end
Expand Down

0 comments on commit 0508940

Please sign in to comment.