From e52afa8c43ca101ea8f325aa67404d2cc958e351 Mon Sep 17 00:00:00 2001 From: Bill Fraser Date: Mon, 26 Oct 2015 03:58:38 -0400 Subject: [PATCH] Move version logic to init.pp fixes #52 --- manifests/init.pp | 11 ++++++++--- manifests/install.pp | 2 +- manifests/params.pp | 23 +++-------------------- spec/classes/grafana_spec.rb | 8 +++----- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 23a3dfe18..e8c7f751d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -63,7 +63,7 @@ # } # class grafana ( - $archive_source = $::grafana::params::archive_source, + $archive_source = "https://grafanarel.s3.amazonaws.com/builds/grafana-${version}.linux-x64.tar.gz", $cfg_location = $::grafana::params::cfg_location, $cfg = $::grafana::params::cfg, $ldap_cfg = $::grafana::params::ldap_cfg, @@ -74,9 +74,14 @@ $install_method = $::grafana::params::install_method, $manage_package_repo = $::grafana::params::manage_package_repo, $package_name = $::grafana::params::package_name, - $package_source = $::grafana::params::package_source, + $package_source = $::osfamily ? { + /(RedHat|Amazon)/ => "https://grafanarel.s3.amazonaws.com/builds/grafana-${version}-${rpm_iteration}.x86_64.rpm", + 'Debian' => "https://grafanarel.s3.amazonaws.com/builds/grafana_${version}_amd64.deb", + default => $archive_source, + }, + $rpm_iteration = $::grafana::params::rpm_iteration, $service_name = $::grafana::params::service_name, - $version = $::grafana::params::version + $version = $::grafana::params::version, ) inherits grafana::params { # validate parameters here diff --git a/manifests/install.pp b/manifests/install.pp index 340227f3f..c32a67eae 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -90,7 +90,7 @@ } package { $::grafana::package_name: - ensure => $::grafana::version, + ensure => "${::grafana::version}-${::grafana::rpm_iteration}", require => Package['fontconfig'] } } diff --git a/manifests/params.pp b/manifests/params.pp index 9ecde58a8..6e39c1402 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,7 +6,6 @@ class grafana::params { $cfg_location = '/etc/grafana/grafana.ini' $cfg = {} - $ldap_cfg = false $container_cfg = false $container_params = {} $data_dir = '/var/lib/grafana' @@ -14,26 +13,10 @@ $docker_ports = '3000:3000' $install_dir = '/usr/share/grafana' $install_method = 'package' + $ldap_cfg = false $manage_package_repo = true $package_name = 'grafana' - $service_name = 'grafana-server' - - $grafana_version = '2.1.0' $rpm_iteration = '1' - $archive_source = "https://grafanarel.s3.amazonaws.com/builds/grafana-${grafana_version}.linux-x64.tar.gz" - - case $::osfamily { - /(RedHat|Amazon)/: { - $version = "${grafana_version}-${rpm_iteration}" - $package_source = "https://grafanarel.s3.amazonaws.com/builds/grafana-${version}.x86_64.rpm" - } - 'Debian': { - $version = $grafana_version - $package_source = "https://grafanarel.s3.amazonaws.com/builds/grafana_${version}_amd64.deb" - } - default: { - $version = $grafana_version - $package_source = $archive_source - } - } + $service_name = 'grafana-server' + $version = '2.1.0' } diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 1f13adef0..3877f8bd4 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -74,8 +74,7 @@ context 'repo install method' do let(:params) {{ :install_method => 'repo', - :manage_package_repo => true, - :version => 'present' + :manage_package_repo => true }} context 'debian' do @@ -95,7 +94,7 @@ end describe 'install the package' do - it { should contain_package('grafana').with_ensure('present') } + it { should contain_package('grafana').with_ensure('2.1.0') } end end @@ -114,7 +113,7 @@ end describe 'install the package' do - it { should contain_package('grafana').with_ensure('present') } + it { should contain_package('grafana').with_ensure('2.1.0-1') } end end end @@ -306,4 +305,3 @@ end end end -