Chef integration with Jenkins

Hello, I am trying to integrate chef with jenkins, below are the steps what tried till now…

  1. Installed chef on separate machine for which i am calling chef-server
    2.Installed Jenkins on separate machine
    3.Installed chef plugins on Jenkins server
    4.Installed chef identity plugin on Jenkins server
    But when i am runing chef-client on Jenkins machine to verify the integration i am getting authentication error.

Platform i am using is ubuntu 16.04

Can anyone please share the exact steps if above steps are not correct …also any other way around to get this integration done will also be appreciated… Thanks in advance.

FYI… I am newbie and trying to learn jenkins pipeline with chef.
Thanks.
Kamlesh

Installing chef-client is not enough to add a new node to chef services. Did you run “knofe bootstrap hostname -N hostname”, with a user with enough privileges to register new hosts?

Thanks for the response,

I already have machine registered with chef-server … let me clear what i am looking here is that …
I wanted to Integrated chef with Jenkins so that my Jenkins server can run the chef-client on registered node which is not happening.
$chef-client
[2018-06-25T16:48:39+05:30] WARN: *****************************************
[2018-06-25T16:48:39+05:30] WARN: Did not find config file: /etc/chef/client.rb, using command line options.
[2018-06-25T16:48:39+05:30] WARN: *****************************************
Starting Chef Client, version 14.2.0
Creating a new client identity for xyz.abc.com using the validator key.
[2018-06-25T16:48:41+05:30] WARN: Failed to read the private key /etc/chef/validation.pem: #<Errno::ENOENT: No such file or directory @ rb_sysopen - /etc/chef/validation.pem>

================================================================================
Chef encountered an error attempting to create the client “bugz01.vra.com

Private Key Not Found:

Your private key could not be loaded. If the key file exists, ensure that it is
readable by chef-client.

Relevant Config Settings:

validation_key “/etc/chef/validation.pem”

System Info:

chef_version=14.2.0
ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
program_name=/usr/bin/chef-client
executable=/opt/chef/bin/chef-client

Running handlers:
[2018-06-25T16:48:41+05:30] ERROR: Running exception handlers
Running handlers complete
[2018-06-25T16:48:41+05:30] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2018-06-25T16:48:41+05:30] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2018-06-25T16:48:41+05:30] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-06-25T16:48:41+05:30] FATAL: Chef::Exceptions::PrivateKeyMissing: I cannot read /etc/chef/validation.pem, which you told me to use to sign requests!

Thanks.

The report of the missing /etc/chef/validation.pem" is what you’d see if running the “knofe bootstrap” command, and not having in hand your local admin privileges and not having in hand a key on the host that would verify chef validation. What, precisely, do you mean by the Jenkins being able to run chef on the other node? Did you bootstrap the other node as well? Which

Until you’ve successfully bootstrapped both nodes, chef-client is unlikely to be able to run on either the jenkins server or the other node. And how do you expect the Jenkins server to connect to the other node to run tasks? That would normally be an SSH command, or a “knofe ssh” command maybe, to connect to the other node and run chef-client.