]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - modules/base_installation/lib/puppet/parser/functions/find_host.rb
Cleanup backup hosts information lookup
[perso/Immae/Projets/Puppet.git] / modules / base_installation / lib / puppet / parser / functions / find_host.rb
1 module Puppet::Parser::Functions
2 newfunction(:find_host, :type => :rvalue, :doc => <<-EOS
3 This function searches through the hosts to find the one with matching cn
4 EOS
5 ) do |arguments|
6
7 if (arguments.size != 2) then
8 raise(Puppet::ParseError, "grep(): Wrong number of arguments given #{arguments.size} for 2")
9 end
10
11 hosts = arguments[0]
12 cn = arguments[1]
13
14 hosts.find { |host| host["cn"].any? { |cn_| cn_ == cn } }
15 end
16 end
17
18 # vim: set ts=2 sw=2 et :