【问题标题】:How do I set up omnibus builder environment on vagrant centos box using chef?如何使用厨师在 vagrant centos 盒子上设置综合构建器环境?
【发布时间】:2016-03-13 22:13:38
【问题描述】:

我需要一个综合构建器框来构建 python cli 包。

我想在this vagrantbox上使用this cookbook

我以 root 身份运行它,因为综合安装程序需要使用 /opt 中的数据检查某些内容

我的 vagrantfile 看起来像这样:

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
  config.vm.box = "centos65opscode"
  # config.vm.provision "chef_solo" do |chef|
  #   chef.add_recipe "omnibus"
  # end
  config.librarian_chef.cheffile_dir = "chef"
  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "chef/cookbooks"
    chef.add_recipe "omnibus"
  end
end

由于 vagrant 的 Librarian chef 插件似乎没有做任何事情,我手动添加了所有依赖项:

我收到此错误:

==> default: NameError
==> default: ---------
==> default: uninitialized constant Chef::Sugar::DSL
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default:   /tmp/vagrant-chef/745d120a7b8f9ecb5d8e9f185062c794/cookbooks/languages/libraries/_helper.rb:31:in `<module:Helper>'
==> default:   /tmp/vagrant-chef/745d120a7b8f9ecb5d8e9f185062c794/cookbooks/languages/libraries/_helper.rb:30:in `<module:Languages>'
==> default:   /tmp/vagrant-chef/745d120a7b8f9ecb5d8e9f185062c794/cookbooks/languages/libraries/_helper.rb:29:in `<top (required)>'
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef/745d120a7b8f9ecb5d8e9f185062c794/cookbooks/languages/libraries/_helper.rb:
==> default:
==> default:  24:  rescue LoadError
==> default:  25:    Chef::Log.warn 'chef-sugar gem could not be loaded.'
==> default:  26:  end
==> default:  27:
==> default:  28:  # Various code vendored from omnibus cookbook
==> default:  29:  module Languages
==> default:  30:    module Helper
==> default:  31>>     include Chef::Sugar::DSL if Chef.const_defined?('Sugar')
==> default:  32:
==> default:  33:      #
==> default:  34:      # Performs a `File.join` but ensures all forward slashes are replaced
==> default:  35:      # by backward slashes.
==> default:  36:      #
==> default:  37:      # @return [String]
==> default:  38:      #
==> default:  39:      def windows_safe_path_join(*args)
==> default:  40:        ::File.join(args).gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR)

【问题讨论】:

    标签: centos vagrant chef-infra chef-solo


    【解决方案1】:

    你试过用vagrant chef provisioning

    Vagrant.configure("2") do |config|
      config.vm.provision "chef_solo" do |chef|
        chef.add_recipe "omnibus"
      end
    end
    

    并将 github omnibus 项目添加到 cookbooks 目录中,如

    .
    |-- Vagrantfile
    |-- cookbooks
    |   |-- omnibus
    |       |-- recipes
    |           |-- default.rb
    |       |-- ...
    

    【讨论】:

    • 所以我需要厨师在盒子上,所以我得到了一个带厨师的盒子:opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/… ~/dev/envs/centos65opscode  cat Vagrantfile # -- mode: ruby -- # vi: set ft=ruby : Vagrant.configure(2) do |config| config.vm.box = "centos65opscode" config.vm.provision "chef_solo" 做 |chef| chef.add_recipe "omnibus" end end ~/dev/envs/centos65opscode  tree . ├── Vagrantfile └── 食谱 └── 综合 |-- ...
    • ==> 默认值:[2016-03-09T09:34:09+00:00] 错误:找不到食谱 7-zip。如果您从另一本食谱加载 7-zip,请确保在元数据中配置依赖项 ==> 默认值:[2016-03-09T09:34:10+00:00] FATAL: Chef::Exceptions::ChildConvergeError : Chef 运行过程未成功退出(退出代码 1)如果这是 linux,为什么我需要 7-zip? 7-zip 是一本 Windows 食谱。另外,在大厨超市,下载7-zip 食谱的文件不是zip 文件,不是tar 文件,不知道那是什么......所以我无法将它解压缩并放在同一个文件夹中。
    • 有没有办法告诉厨师在线获取这种依赖关系?与 pip 从 pypi 获取 python 依赖项的方式相同?
    • 我知道有些人使用librarian chef 来管理这些依赖项
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-27
    • 1970-01-01
    • 2012-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多