Puppet Function: find_linecard

Defined in:
lib/puppet/parser/functions/find_linecard.rb
Function type:
Ruby 3.x API

Overview

find_linecard()Any

Returns:

  • (Any)


29
30
31
32
33
34
35
36
37
# File 'lib/puppet/parser/functions/find_linecard.rb', line 29

newfunction(:find_linecard, type: :rvalue) do |args|
  data = lookupvar('cisco')
  return '' if data.nil?

  pat = Regexp.new(args[0])
  inv = data['inventory']
  match = inv.keys.select { |slot| inv[slot]['pid'].match(pat) }
  match.empty? ? '' : match[0][/(\d+)/]
end