43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/puppet-pssh.rb', line 43
def get_nodes(puppetmaster)
url = "#{use_ssl? ? 'https' : 'http'}://#{puppetmaster}:#{puppetmaster_port}/nodes"
Log.debug "Puppet master host: #{puppetmaster}"
Log.debug "Puppet master url: #{url}"
nodes = []
begin
out = Excon.get url
JSON.parse(out.body).each do |n|
next unless n =~ /#{match}/
nodes << n
end
rescue TypeError => e
raise Exception.new "Error retrieving node list from master host: #{puppetmaster}"
rescue Excon::Errors::SocketError => e
raise Exception.new "Could not connect to the puppet master host: #{puppetmaster}"
end
nodes
end
|