Fix Automate Failing Phases Knife Eval

Sean Horn -

Problem:

A standard Automate 0.6.36, 0.7.239, or 0.8.5 runner install, when there are custom changes to /etc/chef/client.rb, will have failing phases that run Berkshelf or ChefSpec because of the `eval` in /var/opt/workspace/.chef/knife.rb referring to /etc/chef/client.rb

Solution:

For example, log into the Automate server and run the following commands to setup a custom chef-client config that sets the environment and disables the ohai passwd plugin.

cd ~
mkdir -p .chef/client.d

cat <<EOF >.chef/client.d/my_custom_config.rb
environment "production"

ohai.disabled_plugins = [:Passwd]
EOF

Now run the "automate-ctl install-runner" command from the home directory and the "knife bootstrap" command that gets run behind the scenes will automatically detect the client.d directory and put it in the runner's "/etc/chef" directory.

Since the /var/opt/delivery/workspace/.chef/knife.rb only does an "eval(IO.read('/etc/chef/client.rb'))" it doesn't evaluate the contents of /etc/chef/client.d/my_custom_config.rb which means things like berks or chefspec in a phase job no longer break. I tested berks to be sure and it works fine.

Have more questions? Submit a request

Comments

Powered by Zendesk