Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
# Set to 'repo' to install Grafana using an apt or yum repository.
# Defaults to 'package'.
#
# [*install_with_apt*]
# Set to 'true' if you want to install the package via apt. The apt repository is NOT managed
# by this module. You can use the puppetlabs-apt module for this task.
# Defaults to false.
#
# [*manage_package_repo*]
# If true this will setup the official grafana repositories on your host. Defaults to true.
#
Expand Down Expand Up @@ -72,6 +77,7 @@
$data_dir = $::grafana::params::data_dir,
$install_dir = $::grafana::params::install_dir,
$install_method = $::grafana::params::install_method,
$install_with_apt = $::grafana::params::install_with_apt,
$manage_package_repo = $::grafana::params::manage_package_repo,
$package_name = $::grafana::params::package_name,
$package_source = $::osfamily ? {
Expand All @@ -88,6 +94,7 @@
if !is_hash($cfg) {
fail('cfg parameter must be a hash')
}
validate_bool($install_with_apt)

class { 'grafana::install': } ->
class { 'grafana::config': } ~>
Expand Down
30 changes: 19 additions & 11 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,28 @@
'package': {
case $::osfamily {
'Debian': {
package { 'libfontconfig1':
ensure => present
if $::grafana::install_with_apt {
package { $::grafana::package_name:
ensure => present,
provider => 'apt',
}
}
else {
package { 'libfontconfig1':
ensure => present
}

wget::fetch { 'grafana':
source => $::grafana::package_source,
destination => '/tmp/grafana.deb'
}
wget::fetch { 'grafana':
source => $::grafana::package_source,
destination => '/tmp/grafana.deb'
}

package { $::grafana::package_name:
ensure => present,
provider => 'dpkg',
source => '/tmp/grafana.deb',
require => [Wget::Fetch['grafana'],Package['libfontconfig1']]
package { $::grafana::package_name:
ensure => present,
provider => 'dpkg',
source => '/tmp/grafana.deb',
require => [Wget::Fetch['grafana'],Package['libfontconfig1']]
}
}
}
'RedHat': {
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$docker_ports = '3000:3000'
$install_dir = '/usr/share/grafana'
$install_method = 'package'
$install_with_apt = false
$ldap_cfg = false
$manage_package_repo = true
$package_name = 'grafana'
Expand Down
20 changes: 19 additions & 1 deletion spec/classes/grafana_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,28 @@
end

context 'package install method' do
context 'debian' do

context 'debian apt' do
let(:facts) {{
:osfamily => 'Debian'
}}
let(:params) {{
:install_with_apt => true
}}

describe 'install the package with apt' do
it { should contain_package('grafana').with_provider('apt') }
it { should contain_package('grafana').with('ensure' => 'present') }
end
end

context 'debian dpkg' do
let(:facts) {{
:osfamily => 'Debian'
}}
let(:params) {{
:install_with_apt => false
}}

download_location = '/tmp/grafana.deb'

Expand Down