I want to install a Gem (kitchen-docker) into ChefDK's Gem path.
What is the best way to install this Gem via Chef itself? Is there a more clever solution than the following?
execute "chef gem install kitchen-docker" do
user "jenkins"
not_if "chef gem list | grep ^kitchen-docker"
end
Some background information: I want to use ChefDK in Jenkins on our CI server to do cookbook testing. The CI server itself should be provisioned by Chef, of course.
Apparently, in order to install a chef gem system-wide (into /opt/chefdk/
), the parameter --no-user-install
of the gem
command can be used through the gem_package
resource:
gem_package "kitchen-docker" do
gem_binary "/opt/chefdk/embedded/bin/gem"
options "--no-user-install"
end
This installs the gem and makes it available to all users running chefdk on the system.