diff options
author | Morgan Haskel <morgan@puppetlabs.com> | 2014-11-10 17:15:11 -0800 |
---|---|---|
committer | Morgan Haskel <morgan@puppetlabs.com> | 2014-11-10 17:15:11 -0800 |
commit | 0a8963fbd384a477ee69917b4dd4c0bb405bc153 (patch) | |
tree | 0fbc4c4d58cfb2906a999f92a98ee51150c88dae | |
parent | d8b86fdcc2711bff15a169552641e6fec0546ccd (diff) | |
parent | 4949cfd21cb97b17006d82f2f192ec9d01b0d1ee (diff) |
Merge pull request #357 from hunner/hasInterfaceWithLookupBug
(PUP-3597) Catch :undefined_variable when Future Parser is enabled on 3.7.x
-rw-r--r-- | lib/puppet/parser/functions/has_interface_with.rb | 14 | ||||
-rwxr-xr-x | spec/acceptance/ensure_packages_spec.rb | 2 | ||||
-rwxr-xr-x | spec/acceptance/ensure_resource_spec.rb | 2 |
3 files changed, 14 insertions, 4 deletions
diff --git a/lib/puppet/parser/functions/has_interface_with.rb b/lib/puppet/parser/functions/has_interface_with.rb index 00e405d..3691524 100644 --- a/lib/puppet/parser/functions/has_interface_with.rb +++ b/lib/puppet/parser/functions/has_interface_with.rb @@ -35,7 +35,13 @@ has_interface_with("lo") => true kind, value = args - if lookupvar(kind) == value + # Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable + # https://tickets.puppetlabs.com/browse/PUP-3597 + factval = nil + catch :undefined_variable do + factval = lookupvar(kind) + end + if factval == value return true end @@ -44,7 +50,11 @@ has_interface_with("lo") => true iface.downcase! factval = nil begin - factval = lookupvar("#{kind}_#{iface}") + # Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable + # https://tickets.puppetlabs.com/browse/PUP-3597 + catch :undefined_variable do + factval = lookupvar("#{kind}_#{iface}") + end rescue Puppet::ParseError # Eat the exception if strict_variables = true is set end if value == factval diff --git a/spec/acceptance/ensure_packages_spec.rb b/spec/acceptance/ensure_packages_spec.rb index 3651f29..ca4b249 100755 --- a/spec/acceptance/ensure_packages_spec.rb +++ b/spec/acceptance/ensure_packages_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'ensure_packages function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || fact('osfamily') == 'windows') do +describe 'ensure_packages function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) && fact('osfamily') != 'windows') do describe 'success' do it 'ensure_packages a package' do apply_manifest('package { "rake": ensure => absent, provider => "gem", }') diff --git a/spec/acceptance/ensure_resource_spec.rb b/spec/acceptance/ensure_resource_spec.rb index f1bfa54..c3d72fc 100755 --- a/spec/acceptance/ensure_resource_spec.rb +++ b/spec/acceptance/ensure_resource_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'ensure_resource function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || fact('osfamily') == 'windows') do +describe 'ensure_resource function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) && fact('osfamily') != 'windows') do describe 'success' do it 'ensure_resource a package' do apply_manifest('package { "rake": ensure => absent, provider => "gem", }') |