ruby - Vagrant 与 librarian-chef 通过 ruby​​_build & rbenv 安装 ruby

标签 ruby chef-infra vagrant rbenv

在过去的几周里,我不得不重新安装我的整个工作环境几次,这可能需要一段时间,所以现在我有了一个雄心勃勃的想法,即使用 vagrant 和 librarian-chef 来创建我的工作环境,以便我拥有的一切要做的是运行一个 bash 脚本,我在中提琴。

所以我第一次做这件事是一个人的 Vagrant ,我进去做了所有的事情并打包了它,它只用了一段时间就很棒.. 包裹是 600mb,所以下一个想法是让 Chef 做这一切。但我之前从未与 Chef 合作过,所以我找到了librarian-chef基本上我 librarian-chef init 并且它生成了一个 cheffile,你可以指定我的 Recipe ,看起来像这样

site 'http://community.opscode.com/api/v1'

cookbook 'apt'
cookbook 'git'
cookbook 'build-essential'
cookbook 'ruby_build',
  git: 'git://github.com/fnichol/chef-ruby_build'
cookbook 'rbenv',
  git: 'git://github.com/fnichol/chef-rbenv'
cookbook 'sqlite',
  git: 'git://github.com/opscode-cookbooks/sqlite.git'
cookbook 'nodejs',
  git: 'http://github.com/mdxp/nodejs-cookbook'
cookbook 'mysql',
  git: 'git://github.com/opscode-cookbooks/mysql.git'
cookbook 'redis',
  git: 'git://github.com/brianbianco/redisio.git'
cookbook 'zlib',
  git: 'git://github.com/opscode-cookbooks/zlib'
cookbook 'wkhtmltopdf',
  git: 'git://github.com/firstbanco/chef-wkhtmltopdf.git'

当你调用 vagrent up

时,你告诉 vagrant 和 chef 构建这些

在 Vagrant 文件中

config.vm.provision :chef_solo do |chef|
  chef.cookbooks_path = ["cookbooks","site-cookbooks"]
  chef.add_recipe "apt"
  chef.add_recipe "build-essential"
  chef.add_recipe "git"
  chef.add_recipe "ruby_build"
  chef.add_recipe "rbenv::install"
  chef.add_recipe "sqlite"
  chef.add_recipe "nodejs"
  chef.add_recipe "mysql"
  chef.add_recipe "redis"
  chef.add_recipe "zlib"
  chef.add_recipe "wkhtmltopdf"
end

现在我想知道是否可以让 ruby_build 安装 1.9.3-p290 我发现了这个 question这似乎有答案,但我得到以下信息

Running chef-solo...
stdin: is not a tty
[2013-05-23T14:31:18+00:00] INFO: *** Chef 10.14.2 ***
[2013-05-23T14:31:18+00:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[build-essential]", "recipe[git]", "recipe[ruby_build]", "recipe[rbenv::install]", "recipe[sqlite]", "recipe[nodejs]", "recipe[mysql]", "recipe[redis]", "recipe[zlib]", "recipe[wkhtmltopdf]"] from JSON
[2013-05-23T14:31:18+00:00] INFO: Run List is [recipe[apt], recipe[build-essential], recipe[git], recipe[ruby_build], recipe[rbenv::install], recipe[sqlite], recipe[nodejs], recipe[mysql], recipe[redis], recipe[zlib], recipe[wkhtmltopdf]]
[2013-05-23T14:31:18+00:00] INFO: Run List expands to [apt, build-essential, git, ruby_build, rbenv::install, sqlite, nodejs, mysql, redis, zlib, wkhtmltopdf]
[2013-05-23T14:31:18+00:00] INFO: Starting Chef Run for precise64
[2013-05-23T14:31:18+00:00] INFO: Running start handlers
[2013-05-23T14:31:18+00:00] INFO: Start handlers complete.

================================================================================
Recipe Compile Error
================================================================================

Chef::Exceptions::RecipeNotFound
--------------------------------
could not find recipe ruby_build for cookbook rbenv

[2013-05-23T14:31:19+00:00] ERROR: Running exception handlers
[2013-05-23T14:31:19+00:00] ERROR: Exception handlers complete
[2013-05-23T14:31:19+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-05-23T14:31:19+00:00] FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe ruby_build for cookbook rbenv
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

我怎样才能通过 ruby​​ build 安装 ruby​​ 是可能的还是不可能的

最佳答案

Librarian 会在本地安装您的 Recipe ,但不会将它们传输到远程 vagrant box。您需要使用 Vagrant Librarian Chef plugin .

另见:

关于ruby - Vagrant 与 librarian-chef 通过 ruby​​_build & rbenv 安装 ruby,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16716871/

相关文章:

ruby-on-rails - 使用 Microsoft Graph 教程 OmniAuth::AuthenticityError Forbidden Erros 构建 Ruby on Rails 应用程序

ruby-on-rails - ruby rails : Best way to show big data report efficiently

mysql - 在 ruby​​ 脚本上使用事件记录和 mysql

ruby - 是否可以在 Chef 中使用 bash 设置 Ruby ENV?

Vagrant 网络与非主机网络冲突

ruby - 在匹配特定条件时拆分字符串

mysql - OpsWorks 部署错误 - Chef::Exceptions::ChildConvergeError

chef-solo - Chef 中的引导问题

postgresql - 尝试授予权限时关系不存在

vagrant - 在 Travis-CI 中启动 Vagrant VM