Skip to content

Instantly share code, notes, and snippets.

@superseb
Created October 10, 2014 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superseb/fdb443e86a8470a276a5 to your computer and use it in GitHub Desktop.
Save superseb/fdb443e86a8470a276a5 to your computer and use it in GitHub Desktop.
Custom function getipaddr
require 'resolv'
module Puppet::Parser::Functions
newfunction(:getIpAddr, :type => :rvalue) do |arguments|
result = Resolv.getaddress arguments[0]
unless result.nil?
result
else
raise(Puppet::ParseError, "No valid A Record found for host #{arguments[0]}")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment