From f59f5292a14915e21970858e17543de12aabca02 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Sun, 26 Mar 2017 11:59:12 +0200 Subject: [PATCH] Migrate to archive module --- .fixtures.yml | 2 +- README.md | 2 +- manifests/daemon.pp | 21 ++++++++++----------- manifests/install.pp | 26 ++++++++++++-------------- metadata.json | 4 ++-- spec/classes/haproxy_exporter_spec.rb | 6 ++---- spec/classes/node_exporter_spec.rb | 6 ++---- 7 files changed, 30 insertions(+), 37 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index c57d09d38..2fd3ba85c 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -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}" diff --git a/README.md b/README.md index 8adaaf7f8..47dc5096e 100644 --- a/README.md +++ b/README.md @@ -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', } ``` diff --git a/manifests/daemon.pp b/manifests/daemon.pp index ca605b9df..cb0efe5a3 100644 --- a/manifests/daemon.pp +++ b/manifests/daemon.pp @@ -25,17 +25,16 @@ 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', @@ -43,7 +42,7 @@ file { "${bin_dir}/${name}": ensure => link, notify => $notify_service, - target => $binary, + target => "/opt/${name}-${version}.${os}-${arch}/${name}", } } 'package': { diff --git a/manifests/install.pp b/manifests/install.pp index d35668617..1e587b5df 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -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, @@ -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': { diff --git a/metadata.json b/metadata.json index a4dccf3d3..4539ebfb4 100644 --- a/metadata.json +++ b/metadata.json @@ -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", diff --git a/spec/classes/haproxy_exporter_spec.rb b/spec/classes/haproxy_exporter_spec.rb index 9ae0a89d3..ceb0ed781 100644 --- a/spec/classes/haproxy_exporter_spec.rb +++ b/spec/classes/haproxy_exporter_spec.rb @@ -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 @@ -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 diff --git a/spec/classes/node_exporter_spec.rb b/spec/classes/node_exporter_spec.rb index e5ed2b7e5..05159e22f 100644 --- a/spec/classes/node_exporter_spec.rb +++ b/spec/classes/node_exporter_spec.rb @@ -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 @@ -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