Created
October 23, 2011 18:21
-
-
Save rottenbytes/1307671 to your computer and use it in GitHub Desktop.
Integrating noah into chef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Noah | |
def noah_get_host(hostname) | |
require "net/http" | |
require "json" | |
noah_server="http://10.251.12.10:9292" | |
url = URI.parse("#{noah_server}/hosts/#{hostname}") | |
req = Net::HTTP::Get.new(url.path) | |
resp = Net::HTTP.new(url.host, url.port).start do |http| | |
http.request(req) | |
end | |
json_data = JSON.parse(resp.body) | |
return json_data | |
end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Chef::Recipe | |
include Noah | |
end | |
host_status=noah_get_host("fraggle") | |
Chef::Log.info("Noah host status : " + host_status["status"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment