Skip to content

Commit

Permalink
Move version logic to init.pp fixes #52
Browse files Browse the repository at this point in the history
  • Loading branch information
bfraser committed Oct 26, 2015
1 parent 99a92e3 commit e52afa8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
11 changes: 8 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
}

package { $::grafana::package_name:
ensure => $::grafana::version,
ensure => "${::grafana::version}-${::grafana::rpm_iteration}",
require => Package['fontconfig']
}
}
Expand Down
23 changes: 3 additions & 20 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,17 @@
class grafana::params {
$cfg_location = '/etc/grafana/grafana.ini'
$cfg = {}
$ldap_cfg = false
$container_cfg = false
$container_params = {}
$data_dir = '/var/lib/grafana'
$docker_image = 'grafana/grafana:latest'
$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'
}
8 changes: 3 additions & 5 deletions spec/classes/grafana_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -306,4 +305,3 @@
end
end
end

0 comments on commit e52afa8

Please sign in to comment.