rubychef-infraredhatchef-recipetheforeman

Configuration error LoadError: cannot load such file -- chef_handler_foreman (require statement in /etc/chef/client.rb)


I am trying to register existing chef-nodes to Foreman. I followed:

https://www.theforeman.org/plugins/foreman_chef/0.5/index.html

This tells me to install chef_handler_foreman gem and put the following in /etc/chef/client.rb:

require 'chef_handler_foreman'

foreman_server_options 'https://your.proxy.server:8443'

foreman_facts_upload true

foreman_reports_upload true

foreman_enc true

I did both.

When I run chef-client , I get:

[root@ip-10-139-67-124 chef]# chef-client

[2017-06-29T13:25:09-04:00] FATAL: Configuration error LoadError: cannot load such file -- chef_handler_foreman

[2017-06-29T13:25:09-04:00] FATAL: /etc/chef/client.rb:4:in `from_string'

[2017-06-29T13:25:09-04:00] FATAL: Aborting due to error in '/etc/chef/client.rb'

[root@ip-10-139-67-124 chef]#

Here is the evidence that I have the gem installed:

[root@ip-10-139-67-124 chef]# gem list | grep chef

chef_handler_foreman (0.2.0)

I am running Redhat 7.3.

I have looked into the following question and few others. Answers to those suggest a case-sensitivity problem, which is not the case here:

LoadError: cannot load such file -- english

What am I doing wrong? Any help is appreciated.


Solution

  • You should check with /opt/chef/embedded/bin/gem list | grep foreman.

    I suspect you have the gem installed in your system ruby and not in chef's ruby bundled in the omnibus installer to avoid clashs with system ruby.

    Usually you should use chef to install gem inside chef and configure itself. Install gems with the chef_gem resource and take advantage of the chef_client cookbook to configure chef.