I want to add httpapi handler
Here is my cookbook
chef_gem 'chef-handler-httpapi'
template "/etc/chef/client.d/httpapi_handler.rb" do
source "httpapi_handler.rb.erb"
mode '0644'
notifies :create, "ruby_block[reload_client_config]"
end
include_recipe 'chef-client::config'
/etc/chef/client.d/httpapi_handler.rb
require "chef-handler-httpapi"
api_url = "http://example.com/api/alerts"
api_user = admin
api_pass = pass
# ssl tweaks
(api_ssl_version = :SSLv3)
(api_ssl_verify = "none")
# name for data_message KEY
api_data_message = "message"
# keys and values for successful run
api_data_success = {
"state" => "INFO",
"class" => "chef-client"
}
# keys and values for failed run
api_data_failed = {
"state" => "FAILED",
"class" => "chef-client"
}
Httpapi_handler = Httpapi.new(api_url, api_user, api_pass, api_ssl_verify, api_ssl_version, api_data_message, api_data_success, api_data_failed)
report_handlers << Httpapi_handler # run at the end of a successful run
exception_handlers << Httpapi_handler # run at the end of a failed run
When I run chef-client I get
[2018-02-06T09:47:11+00:00] FATAL: Configuration error LoadError: cannot load such file -- chef-handler-httpapi
[2018-02-06T09:47:11+00:00] FATAL: /etc/chef/client.d/httpapi_handler.rb:1:in `from_string'
[2018-02-06T09:47:11+00:00] FATAL: Aborting due to error in '/etc/chef/client.d/httpapi_handler.rb'
chef_gem is installed
/opt/chef/embedded/bin/gem list | grep http
chef-handler-httpapi (0.0.2)
Chef Client, version 12.21.31
- chef-client (9.0.5)
- chef_handler (3.0.2)