From 54be9570a3de6370b3c1e6779c1719eacc50b947 Mon Sep 17 00:00:00 2001 From: Stuart Fox Date: Thu, 10 Mar 2016 23:28:04 +0000 Subject: [PATCH] Refactor install class to handle manage_repo being set to false This commit lightly refactors the install class so that Puppet doesn't fail when `manage_repo` is set to `false`. Fixes #7. --- manifests/install.pp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 3f2ad1d..8b3840c 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -9,9 +9,9 @@ $_operatingsystem = downcase($::operatingsystem) - case $::osfamily { - 'Debian': { - if $::telegraf::manage_repo { + if $::telegraf::manage_repo { + case $::osfamily { + 'Debian': { apt::source { 'influxdata': comment => 'Mirror for InfluxData packages', location => "https://repos.influxdata.com/${_operatingsystem}", @@ -22,14 +22,9 @@ 'source' => 'https://repos.influxdata.com/influxdb.key', }, } + Class['apt::update'] -> Package['telegraf'] } - ensure_packages(['telegraf'], { - 'ensure' => $::telegraf::ensure, - 'require' => Exec['apt_update'], - }) - } - 'RedHat': { - if $::telegraf::manage_repo { + 'RedHat': { yumrepo { 'influxdata': descr => 'influxdata', enabled => 1, @@ -37,14 +32,14 @@ gpgkey => 'https://repos.influxdata.com/influxdb.key', gpgcheck => true, } + Yumrepo['influxdata'] -> Package['telegraf'] + } + default: { + fail('Only RedHat, CentOS, Debian and Ubuntu are supported at this time') } - ensure_packages(['telegraf'], { - 'ensure' => $::telegraf::ensure, - 'require' => Yumrepo['influxdata'], - }) - } - default: { - fail('Only RedHat, CentOS, Debian and Ubuntu are supported at this time') } } + + ensure_packages(['telegraf'], { ensure => $::telegraf::ensure }) + }