From a9ac08d7a4dd000ea254973d357f5d1598278ce9 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Sun, 27 Jul 2014 12:09:17 -0700 Subject: [PATCH] Case out unused parameters in rules.pp Was breaking because of empty source in puppet 3.6.2 --- manifests/rule.pp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/manifests/rule.pp b/manifests/rule.pp index db0280e..8cbd2bc 100644 --- a/manifests/rule.pp +++ b/manifests/rule.pp @@ -48,34 +48,38 @@ include udev # only $source or $content are allowed + + $config_base = { + ensure => $ensure, + owner => 'root', + group => 'root', + mode => '0644', + notify => Class['udev::udevadm::trigger'], + } if $source { validate_string($source) if $content { fail("${title}: parameters \$source and \$content are mutually exclusive") } + $config_content = { source => $source } } elsif $content { validate_string($content) if $source { fail("${title}: parameters \$source and \$content are mutually exclusive") } + $config_content = { content => $content } } else { # one of $source or $content is required unless we're removing the file, if $ensure != 'absent' { fail("${title}: parameter \$source or \$content is required") + } else { + $config_content = {} } } - $config = { - ensure => $ensure, - owner => 'root', - group => 'root', - mode => '0644', - content => $content, - source => $source, - notify => Class['udev::udevadm::trigger'], - } + $config = merge($config_base, $config_content) create_resources( 'file', { "/etc/udev/rules.d/${title}" => $config } )