Skip to content

Commit

Permalink
Refactor install class to handle manage_repo being set to false
Browse files Browse the repository at this point in the history
This commit lightly refactors the install class so that Puppet doesn't
fail when `manage_repo` is set to `false`.

Fixes voxpupuli#7.
  • Loading branch information
stuartbfox committed Mar 10, 2016
1 parent 489a6c7 commit 54be957
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand All @@ -22,29 +22,24 @@
'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,
baseurl => "https://repos.influxdata.com/rhel/${::operatingsystemmajrelease}/${::architecture}/stable",
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 })

}

0 comments on commit 54be957

Please sign in to comment.