Chef infra Vagrant在基础映像的顶部安装chef客户端

Chef infra Vagrant在基础映像的顶部安装chef客户端,chef-infra,vagrant,Chef Infra,Vagrant,我正在尝试使用Chef安装graphite服务器,但我遇到了一个错误,即在VM上找不到Chef solo或Chef client。我使用的是Ubuntu12.04.amd64 LTS,这是服务器版本,所以不会安装chef客户端。我知道13版将自动安装厨师客户端,但我不能使用13版 我在谷歌上搜索,看到一些人建议使用ssh连接到box,并安装chef客户端 我的问题是:在chef启动之前,我是否可以预先安装chef客户端?基本上,我希望我的厨师程序下载原始图像和做任何事情没有额外的手动步骤从用户。

我正在尝试使用Chef安装graphite服务器,但我遇到了一个错误,即在VM上找不到Chef solo或Chef client。我使用的是Ubuntu12.04.amd64 LTS,这是服务器版本,所以不会安装chef客户端。我知道13版将自动安装厨师客户端,但我不能使用13版

我在谷歌上搜索,看到一些人建议使用ssh连接到box,并安装chef客户端

我的问题是:在chef启动之前,我是否可以预先安装chef客户端?基本上,我希望我的厨师程序下载原始图像和做任何事情没有额外的手动步骤从用户。可能吗

我的流浪汉档案:

Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu-12.04-amd64"
    config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
    config.vm.hostname = "graphite"
    config.vm.network :forwarded_port, guest: 8080, host: 9090

    config.vm.provision :chef_solo do |chef|
      chef.cookbooks_path = "cookbooks"
      chef.roles_path = "roles"
      chef.data_bags_path = "data_bags"
      chef.add_role "Graphite-Server"
      chef.add_role "StatsD-Server"
    end
end
错误日志:

[default] Running provisioner: chef_solo...
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.

谢谢

如果没有安装chef,我可以向您推荐基本上执行
install.sh
脚本的插件。

我找到了两种解决方案,两种方案都能正常工作:

1)方法1: 在您的文件中,添加

config.omnibus.chef\u版本=:最新版本

这将确保虚拟机上安装了chef solochef client,并且是厨师资源调配所必需的。要使用omnibus插件,请确保首先安装插件:
vagrant插件安装vagrant omnibus

2)方法2:使用
config.vm.provision
shell内联,如下所述:。在您的文件中,添加:

config.vm.provision“shell”,路径:“utils/tools/install\u chef.bash”

我编写的脚本utils/tools/install\u chef.bash如下所示:

#!/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
更新:


如果出现以下错误:
未知配置部分“omnibus”
。这意味着您缺少omnibus插件。要安装它,请键入:
vagrant-plugin-install-vagrant-omnibus

我在这里找到了一些解决方案:如果预先安装了chef,这取决于您的基本设备。我非常确定Ubuntu13.*也安装了chef Preested,只能通过
apt
使用。对不起,我的意思是“Ubuntu13.*也没有安装chef”,或者只是使用Test Kitchen:)当然,也可以。我以前也有过类似的经历。如果您的internet连接速度较慢,您可以将
.deb
文件放在某个位置,该位置可以通过同步文件夹获得(或者放在目录下,您的
文件所在的位置,或者使用其他共享)。然后你只需执行
dpkg-i chef*.deb
即可安装chef,无需反复下载。嗯。。。好主意。这可能是解决这个问题的第三种方法。我要试试看!谢谢@StephenKing