summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/has_interface_with.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/functions/has_interface_with.rb')
-rw-r--r--lib/puppet/parser/functions/has_interface_with.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/puppet/parser/functions/has_interface_with.rb b/lib/puppet/parser/functions/has_interface_with.rb
index 7f150a7..3691524 100644
--- a/lib/puppet/parser/functions/has_interface_with.rb
+++ b/lib/puppet/parser/functions/has_interface_with.rb
@@ -25,7 +25,7 @@ has_interface_with("lo") => true
interfaces = lookupvar('interfaces')
# If we do not have any interfaces, then there are no requested attributes
- return false if (interfaces == :undefined)
+ return false if (interfaces == :undefined || interfaces.nil?)
interfaces = interfaces.split(',')
@@ -35,13 +35,29 @@ 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
result = false
interfaces.each do |iface|
- if value == lookupvar("#{kind}_#{iface}")
+ iface.downcase!
+ factval = nil
+ begin
+ # 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
result = true
break
end