summaryrefslogtreecommitdiffstats
path: root/fuel/build/f_l23network/puppet/modules/l23network/lib/puppet/parser/functions/extras_to_hosts.rb
blob: 33bfad8fd8f6fc8cc335d8e4b9806d063a7ac88a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# array_or_string_to_array.rb
#

module Puppet::Parser::Functions
  newfunction(:extras_to_hosts, :type => :rvalue, :doc => <<-EOS
              convert extras array passed from Astute into
              hash for puppet `host` create_resources call
    EOS
  ) do |args|
    hosts=Hash.new
    extras=args[0]
    extras.each do |extras|
      hosts[extras['name']]={:ip=>extras['address'],:host_aliases=>[extras['fqdn']]}
      notice("Generating extras host entry #{extras['name']} #{extras['address']} #{extras['fqdn']}")
    end
    return hosts
  end
end

# vim: set ts=2 sw=2 et :