【问题标题】:Vagrant Box Breaking After Knife Cookbook Installs刀食谱安装后流浪者盒子破裂
【发布时间】:2012-11-23 21:47:15
【问题描述】:

我是一个 Vagrant n00b,在使用 chef-solo 设置一个非常简单的 CentOS LAMP 盒子时,我在让 Vagrant 和 Chef 的 knife 命令一起玩时遇到问题。

以下是该问题的简要说明:

  1. 我在 vagrantbox.es 上使用 CentOS 6.3 w/ Chef 基本框创建了一个基本的 Vagrantfile。您可以在this gist 中查看基础知识。
  2. 我已经通过knife cookbook site install nameofcookbook 下载了所有食谱,并使用将它们放入./chef/cookbooks 的配置。
  3. 我已经成功运行vagrant up to 你可以在this gist看到基础。
  4. 我已经测试过apache、php等,都很好。
  5. 现在诀窍来了:在 VM 运行的情况下,我运行 Knife 添加另一个包(在本例中为 i3)
  6. 从这里开始,Vagrant 无法在 VM 中执行各种任务:
  7. 当我运行 vagrant provision 时,我收到这样的错误

    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.
    
  8. 当我运行 vagrant halt 时,我收到一个错误,即 ssh 命令以非零错误代码退出。

  9. 但是,我可以运行 vagrant ssh,并确认 (a) chef-solo 实际上存在于框中,并且 (b) 我可以通过框中的命令行关闭。
  10. 当我运行 vagrant up 时,我收到如下错误:
    The following SSH command responded with a non-zero exit status.
    Vagrant assumes that this means the command failed!
    mkdir -p /vagrant</li>
    

我难住了。我已经在两个盒子上发生过这种情况,而且我知道 Knife 和 Vagrant 应该能够很好地配合使用。

我做错了什么?

非常感谢您的帮助,我对深入研究 Vagrant 感到非常兴奋!

【问题讨论】:

    标签: centos chef-infra vagrant knife


    【解决方案1】:
    chef.add_recipe "sudo"
    

    在第一次运行后删除你的 sudo 文件。

    为您的 vagrant 用户添加适当的 json 到您的 vagrant 文件中。

    类似:

    config.vm.provision :chef_solo do |chef|
    
      # add your recipes
      # chef.add_recipe "foo"
      # chef.add_role   "bar"
      chef.json = {
        "authorization" => {
            "sudo" => {
                "users" => [ "vagrant" ],
                "passwordless" => true,
            }
        }
      }
    end
    

    【讨论】:

    • 我不明白“第一次运行后删除了你的 sudo 文件”
    • @Vdt 厨师 sudo 配方更新 /etc/sudoers 删除了“vagrant”用户的 sudo 权限。除非您按上面所示添加该用户,否则您将无法再次运行 chef,因为它需要 sudo。
    • chef-solo 或 chef-client 在 VM 中根本找不到,它似乎不像你的 json install chef-solo/chef-client 是吗?
    • @holms 是的,您的虚拟机需要安装 chef 才能使上述功能正常工作。
    • 我在我的 Vagrant 文件中使用了这个 config.omnibus.chef_version = :latest,并在 vagrant plugin install vagrant-omnibus 之前安装了 vagrant 插件
    猜你喜欢
    • 1970-01-01
    • 2013-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多