How to use chef-provisioning-ssh in build cookbook

I am trying to use the ssh provisioning driver in build-cookbook::provision. If I do:

require 'chef/provisioning/ssh_driver'
with_driver 'ssh'

I get a load error (i.e. the gem isnt installed). However, if I logon to the build node and do chef gem install chef-provisioning-ssh, the problem remains, so I assume it’s working off a different gem path.

I then tried adding:

chef_gem 'chef-provisioning-aws'

This gave me an error about not being able to write to the provisioning/ssh directory in the acceptance workspace. I logged onto the build node and created the provisioning directory (with ownership dbuild) and the provision phase ran successfully, but after that the whole build node was completely broken. No phases would run at all (“Could not start phase run. No build nodes available”). The only thing I could do was destroy the build node and recreate it.

So hoping someone can point me in the right direction before I trash more stuff.

Hi Christine,

The problem you are facing is because you are trying to install a gem on the actual phase recipe and that recipe is run by the dbuild user which does not have privileges to install gem’s on the system.

In order to fix this there is an special recipe that is dedicated to put all the software you need to install before running an specific phase. That is the default recipe. So just move the chef_gem resource to that recipe and you will be fine! :smile:

I’ll try that when I get a chance, but I believe I got the provisioning-ssh
gem installed ok (perhaps on a previous run). I know the provisioning ssh
driver writes some information into .chef/provisioning/ssh, and the error I
got indicated the chef-client did not have permission to write there
(scripts running as dbuild, whereas .chef owned by root).