I\'m trying to use Chef to install graphite server and I encountered errors saying that either chef-solo or chef-client was not found on the VM. I\'m using Ubuntu 12.04.amd64 LT
I can recommend the vagrant-omnibus plugin that basically executes the install.sh
script for you, if chef is not installed.
I found 2 solutions and both work as expected:
1) Method 1: In your Vagrantfile, add
config.omnibus.chef_version = :latest
This will make sure either chef-solo or chef-client is installed on the VM and is required for chef provisioning. In order to use omnibus plugin, make sure you install the plugin first: vagrant plugin install vagrant-omnibus
2) Method 2: Use config.vm.provision
shell inline as mentioned here: https://github.com/mitchellh/vagrant-aws/issues/19#issuecomment-15487131. In your Vagrantfile, add:
config.vm.provision "shell", path: "utils/tools/install_chef.bash"
The script utils/tools/install_chef.bash that I wrote looks like this:
#!/bin/bash
function error
{
echo -e "\033[1;31m${1}\033[0m" 1>&2
}
function checkRequireRootUser
{
if [[ "$(whoami)" != 'root' ]]
then
error "ERROR: please run this program as 'root'"
exit 1
fi
}
function installChef()
{
if [[ "$(which chef-client)" = '' ]]
then
local chefProfilePath='/etc/profile.d/chef.sh'
curl -s -L 'https://www.opscode.com/chef/install.sh' | bash && \
echo 'export PATH="/opt/chef/embedded/bin:$PATH"' > "${chefProfilePath}" && \
source "${chefProfilePath}"
fi
}
function main()
{
checkRequireRootUser
installChef
}
main
UPDATE:
if you get following error: Unknown configuration section 'omnibus'
. It means you are missing omnibus plugin. To install it, type: vagrant plugin install vagrant-omnibus