Created
May 22, 2015 11:51
-
-
Save paaloeye/69a96bdb079a50b01216 to your computer and use it in GitHub Desktop.
hash_join_dnsmasq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put in $module/lib/puppet/parser/functions/hash_join_dnsmasq.rb | |
module Puppet::Parser::Functions | |
newfunction(:hash_join_dnsmasq, :type => :rvalue, :arity => 2, :doc => <<-EOS | |
Take hash and string, join them for dnsmasq. | |
EOS | |
) do |arguments| | |
hash = arguments[0] | |
ip = arguments[1] | |
array = hash.map { |key, value| "#{key}/#{value}" } | |
array.zip(array.count.times.map { ip }).map { |el| el.join(',')}.join(',') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment