def main
Puppet.warning "Failed to load ruby LDAP library. LDAP functionality will not be available" unless Puppet.features.ldap?
require 'puppet/util/ldap/connection'
todo = @hosts.dup
failures = []
go = true
while go
if @children.length < options[:parallel] and ! todo.empty?
host = todo.shift
pid = safe_posix_fork do
run_for_host(host)
end
@children[pid] = host
else
begin
pid = Process.wait
if host = @children[pid]
@children.delete(pid)
failures << host if $CHILD_STATUS.exitstatus != 0
print "#{host} finished with exit code #{$CHILD_STATUS.exitstatus}\n"
else
$stderr.puts "Could not find host for PID #{pid} with status #{$CHILD_STATUS.exitstatus}"
end
rescue Errno::ECHILD
next unless todo.empty?
if failures.empty?
puts "Finished"
exit(0)
else
puts "Failed: #{failures.join(", ")}"
exit(3)
end
end
end
end
end