Bug #122 ยป 0001-Only-output-yaml-when-node-is-found-for-puppetmaster.patch
config/routes.rb | ||
---|---|---|
map.root :controller => "hosts"
|
||
map.connect "node/:name", :controller => 'hosts', :action => 'externalNodes',
|
||
:requirements => { :name => /(.+\.)+\w+/ }
|
||
:requirements => { :name => /[^\.][\w\.-]+/ }
|
||
map.connect "/hosts/query", :controller => 'hosts', :action => 'query'
|
||
map.resources :hosts,
|
||
:member => {:report => :get, :reports => :get, :facts => :get},
|
extras/puppet/foreman/files/external_node.rb | ||
---|---|---|
# you can basically use anything that knows how to get http data, e.g. wget/curl etc.
|
||
# Foreman url
|
||
url="http://foreman:3000"
|
||
foreman_url="http://foreman:3000"
|
||
require 'net/http'
|
||
Net::HTTP.get_print URI.parse("#{url}/node/#{ARGV[0]}?format=yml")
|
||
foreman_url += "/node/#{ARGV[0]}?format=yml"
|
||
url = URI.parse(foreman_url)
|
||
req = Net::HTTP::Get.new(foreman_url)
|
||
res = Net::HTTP.start(url.host, url.port) { |http|
|
||
http.request(req)
|
||
}
|
||
case res
|
||
when Net::HTTPOK
|
||
puts res.body
|
||
else
|
||
$stderr.puts "Error retrieving node %s: %s" % [ARGV[0], res.class]
|
||
end
|
||