Vagrant在基础映像之上安装Chef-client [英] Vagrant Install chef-client on top of base image

查看:98
本文介绍了Vagrant在基础映像之上安装Chef-client的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Chef安装石墨服务器,但遇到错误,指出在VM上未找到Chef-solo或Chef-client。我使用的是Ubuntu 12.04.amd64 LTS,它是服务器版本,因此不会安装Chef-Client。我知道13版本会自动安装Chef-client,但我不能使用13版本。

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 LTS, this is server version so it will not have chef-client installed. I know that 13 version will auto have chef-client installed but I can not use 13 version.

我用Google搜索了一下,看到有人建议把它装到盒子里,然后

I googled and saw some people suggest to ssh to the box and apt-get install chef-client.

我的问题是:在厨师加入之前,我是否可以预先安装Chef-client?基本上,我想让我的厨师程序下载原始图像并执行所有操作,而无需用户进行其他手动操作。

My question is: is there anyway that I can preinstall chef-client before chef kicked in? Basically I would like my chef program download the raw image and do everything without additional manual steps from users. Is it possible?

我的Vagrantfile:

My Vagrantfile:

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.

谢谢

推荐答案

我找到了2个解决方案,并且都可以按预期工作:

I found 2 solutions and both work as expected:

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

1) Method 1: In your Vagrantfile, add

config.omnibus.chef_version =:latest

这将确保 chef-solo chef-client 已安装在VM上,并且是厨师配置的必需条件。为了使用omnibus插件,请确保首先安装插件: vagrant插件安装vagrant-omnibus

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)方法2:使用 config.vm.provision shell内联,如下所述: https://github.com/mitchellh/vagrant-aws/issues/19#issuecomment-15487131 。在您的Vagrantfile中,添加:

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,路径: utils / tools / install_chef.bash

我编写的脚本 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

更新:

未知配置节综合 。这意味着您缺少omnibus插件。要安装它,请输入: vagrant plugin install vagrant-omnibus

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

这篇关于Vagrant在基础映像之上安装Chef-client的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆