Skip to content

Commit

Permalink
Use $facts hash instead of topscope variables
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjfisher committed Nov 6, 2017
1 parent 15a028f commit 4489e60
Show file tree
Hide file tree
Showing 35 changed files with 44 additions and 44 deletions.
10 changes: 5 additions & 5 deletions manifests/params.pp
Expand Up @@ -26,12 +26,12 @@
$plugin_conf_dir_mode = '0750'
$ci_package_repo = undef

case getvar('::kernel') {
'OpenBSD': { $has_wordexp = false }
default: { $has_wordexp = true }
case $facts['kernel'] {
'OpenBSD': { $has_wordexp = false }
default: { $has_wordexp = true }
}

case $::osfamily {
case $facts['os']['family'] {
'Debian': {
$package_name = [ 'collectd', 'collectd-core' ]
$package_provider = 'apt'
Expand Down Expand Up @@ -130,7 +130,7 @@
}

default: {
fail("${::osfamily} is not supported.")
fail("${facts['os']['family']} is not supported.")
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/amqp.pp
Expand Up @@ -23,7 +23,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-amqp':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/apache.pp
Expand Up @@ -11,7 +11,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-apache':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/bind.pp
Expand Up @@ -18,7 +18,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-bind':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/cuda.pp
Expand Up @@ -29,7 +29,7 @@
require => Package['python-pip'],
}

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
# Epel is installed in install.pp if manage_repo is true
# python-pip doesn't exist in base for RedHat. Need epel installed first
if (defined(Class['::epel'])) {
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/curl.pp
Expand Up @@ -10,7 +10,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-curl':
ensure => $ensure,
Expand Down
6 changes: 3 additions & 3 deletions manifests/plugin/curl_json.pp
Expand Up @@ -24,15 +24,15 @@
$_manage_package = pick($manage_package, $::collectd::manage_package)

if $_manage_package {
if $::osfamily == 'Debian' {
$libyajl_package = $::lsbdistcodename ? {
if $facts['os']['family'] == 'Debian' {
$libyajl_package = $facts['os']['lsb']['distcodename'] ? {
'precise' => 'libyajl1',
default => 'libyajl2'
}
ensure_packages($libyajl_package)
}

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
ensure_packages('collectd-curl_json')
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/dbi.pp
Expand Up @@ -12,7 +12,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-dbi':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/disk.pp
Expand Up @@ -11,7 +11,7 @@

include ::collectd

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $manage_package != undef {
$_manage_package = $manage_package
} else {
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/genericjmx.pp
Expand Up @@ -13,7 +13,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-generic-jmx':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/ipmi.pp
Expand Up @@ -15,7 +15,7 @@

$manage_package_real = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $manage_package_real {
package { 'collectd-ipmi':
ensure => $ensure_package,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/iptables.pp
Expand Up @@ -12,7 +12,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-iptables':
ensure => $ensure_package,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/iscdhcp.pp
Expand Up @@ -28,7 +28,7 @@
require => Package['python-pip'],
}

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
# Epel is installed in install.pp if manage_repo is true
# python-pip doesn't exist in base for RedHat. Need epel installed first
if (defined(Class['::epel'])) {
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/java.pp
Expand Up @@ -12,7 +12,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-java':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/lvm.pp
Expand Up @@ -15,7 +15,7 @@
$ensure_real = 'absent'
}

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-lvm':
ensure => $ensure_real,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/mysql.pp
Expand Up @@ -10,7 +10,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-mysql':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/netlink.pp
Expand Up @@ -15,7 +15,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-netlink':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/nginx.pp
Expand Up @@ -15,7 +15,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-nginx':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/perl.pp
Expand Up @@ -12,7 +12,7 @@

$conf_dir = $collectd::plugin_conf_dir

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-perl':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/ping.pp
Expand Up @@ -15,7 +15,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-ping':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/postgresql.pp
Expand Up @@ -12,7 +12,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-postgresql':
ensure => $ensure,
Expand Down
4 changes: 2 additions & 2 deletions manifests/plugin/rabbitmq.pp
Expand Up @@ -61,7 +61,7 @@
) {
include ::collectd

case $::osfamily {
case $facts['os']['family'] {
'RedHat': {
$_custom_types_db = '/usr/share/collectd-rabbitmq/types.db.custom'
}
Expand All @@ -81,7 +81,7 @@
require => Package['python-pip'],
}

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
# Epel is installed in install.pp if manage_repo is true
# python-pip doesn't exist in base for RedHat. Need epel installed first
if (defined(Class['::epel'])) {
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/redis.pp
Expand Up @@ -22,7 +22,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-redis':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/rrdcached.pp
Expand Up @@ -19,7 +19,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-rrdcached':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/rrdtool.pp
Expand Up @@ -17,7 +17,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-rrdtool':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/sensors.pp
Expand Up @@ -12,7 +12,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-sensors':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/smart.pp
Expand Up @@ -10,7 +10,7 @@

include ::collectd

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $manage_package != undef {
$_manage_package = $manage_package
} else {
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/snmp.pp
Expand Up @@ -11,7 +11,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-snmp':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/varnish.pp
Expand Up @@ -13,7 +13,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-varnish':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/virt.pp
Expand Up @@ -17,7 +17,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-virt':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/write_riemann.pp
Expand Up @@ -18,7 +18,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-write_riemann':
ensure => $ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/write_sensu.pp
Expand Up @@ -16,7 +16,7 @@

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $::osfamily == 'RedHat' {
if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-write_sensu':
ensure => $ensure,
Expand Down
4 changes: 2 additions & 2 deletions manifests/repo.pp
Expand Up @@ -3,12 +3,12 @@
class collectd::repo {

if $collectd::manage_repo {
$osfamily_downcase = downcase($::osfamily)
$osfamily_downcase = downcase($facts['os']['family'])

if defined("::collectd::repo::${osfamily_downcase}") {
require "::collectd::repo::${osfamily_downcase}"
} else {
notify{"You have asked to manage_repo on a system that doesn't have a repo class specified: ${::osfamily}":}
notify{"You have asked to manage_repo on a system that doesn't have a repo class specified: ${facts['os']['family']}":}
}
}

Expand Down
4 changes: 2 additions & 2 deletions manifests/repo/debian.pp
Expand Up @@ -13,8 +13,8 @@
},
}
} else {
if $::operatingsystem == 'Debian' {
warning('Youre trying to use the Ubuntu PPA on a Debian Server, which may cause errors')
if $facts['os']['name'] == 'Debian' {
warning('You\'re trying to use the Ubuntu PPA on a Debian Server, which may cause errors')
warning('We recommend you to use the $ci_package_repo parameter if you want to use an upstream repo on Debian')
} else {
apt::source { 'ppa_collectd':
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/collectd_init_spec.rb
Expand Up @@ -253,7 +253,7 @@
it { is_expected.to contain_file('collectd.conf').with_content(%r{Hello World}) }
end
context 'on non supported operating systems' do
let(:facts) { { osfamily: 'foo' } }
let(:facts) { { os: { family: 'foo' } } }

it 'fails' do
is_expected.to compile.and_raise_error(%r{foo is not supported})
Expand Down

0 comments on commit 4489e60

Please sign in to comment.