Unable to run run chef-client without ruby gems(no internet access)


I am trying to run chef-client (without internet access) so it fetches for ruby gem which i kept in artifactory .
I have run the below manual steps to add the repository path to ruby gem:

The bootstrap of the Windows node through Jenkins is successful when I do not mention any run list.
But, when I mention run list, it starts executing chef-client, which in turn tries to fetch few required gems from https://rubygems.org . As the node does not have internet access, it fails.

  1.   execute “gem sources –a /path/to/artifactory’s/gems/repository”
  2.   execute “gem sources –r https://rubygems.org”

The above two steps help us in fetching the gems from artifactory instead of the official gems repository.
3. Execute chef-client

The same command I am unable to run using the jenkins .I tried with winrm option but no success.

Can anyone help me out in this.

Thanks in advance

I was facing the same issue and solved by writing a bootstrap/base cookbook which does not need any external gems or so but configures the system with everything I needed (certificates, config etc). The cookbook can be run separately by “chef-client -o my-bootstrap-cookbook” or by passing it to the knife bootstrap command.
To configure gems you can place a gemrc in /etc/gemrc, /root/.gemrc and /opt/chef/embedded/etc/gemrc. The global config in /etc should be enough, but just to be sure. Heres an example gemrc: https://gist.github.com/jch/1331576


Thanks for your response …I have kept my gems in the artifactory can you please elaborate how that can be used while bootstrapping .I do not have idea how this can be used while bootstrapping itself . Is there anyway how the installation of gems can be done using the bootstrapping itself

Actually, I did answer exactly this question, or at least how I solved this.
Just configure artifactory as your gem repo on your severs using the config(s) I mentioned and chef will be able to install the gems…


Thanks for your valuable information… Actually I got confused how to use the command with bootstrap …as chef-client will run on node side and you have mentioned “chef-client -o my-bootstrap-cookbook” and later you told that include in knife command …So it will be great help if you can let me know the complete command and from where to run it…

I am new to Chef… It will be great help for me…

Thanks a lot in advance

Ah, ok. So, the reason I was not very specific is because there are many many ways to bootstrap a machine. If you use knife you can use “knife bootstrap -r bootstrap-cookbook” which will run the bootstrap-cookbook on the initial chef run. If you do your bootstrapping using the validator key and the chef-client you can set the run list for the inital chef run with “chef-client -o bootstrap-cookbook”.
And those are just two ways which are quite common… :wink:

Thanks a lot…