我尝试使用chef_handler
食谱在厨师中报告,reportchef
当我尝试将其上传到服务器时:
require 'net/http'
require 'uri'
class ReportChef < Chef::Handler
def initialize(opts = nil)
@opts = opts
unless opts[:api_key]
Chef::Application.fatal!("No ReportChef API Key set")
end
end
def report
params = @opts.merge({ node_name: run_status.node.fqdn })
if run_status.failed?
params[:last_run_successful] = false
params[:exception] = run_status.formatted_exception
params[:backtrace] = run_status.backtrace.join("\n")
else
params[:last_run_successful] = true
end
uri = URI.parse("http://reportchef.com/api/v1/reports")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data(params)
response = http.request(request)
end
end
错误
knife cookbook upload reportchef -c /etc/chef/knife.rb
Uploading reportchef [1.0.1]
FATAL: Cookbook file files/default/reportchef.rb has a ruby syntax error:
FATAL: /software/chef-repo/cookbooks/reportchef/files/default/reportchef.rb:13: syntax
error
FATAL: params = @opts.merge({ node_name: run_status.node.fqdn })
FATAL: ^
FATAL: /software/chef-repo/cookbooks/reportchef/files/default/reportchef.rb:13: syntax
error
FATAL: params = @opts.merge({ node_name: run_status.node.fqdn })
FATAL:
发生了什么?
它是下载的代码。