gpt4 book ai didi

ruby - 使用 Chef 配置构建 Vagrantfile 不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 16:47:46 24 4
gpt4 key购买 nike

我正在尝试按照以下文本教程进行操作,但我的设置在他键入“bundle install”时中断,我的设置没有安装 bundle,很明显我的 Chef 东西有问题 - https://gorails.com/guides/using-vagrant-for-rails-development

编辑:为什么这个问题被否决了?我没有提供一些背景吗?

我运行了前两个命令。

vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-librarian-chef-nochef

我创建了一个文件夹并制作了 Cheffile 和 Vagrantfile,如下所示:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
config.vm.box = "ubuntu/trusty64"

# Configurate the virtual machine to use 2GB of RAM
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end

# Forward the Rails server default port to the host
config.vm.network :forwarded_port, guest: 3000, host: 3000

# Use Chef Solo to provision our virtual machine
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"

chef.add_recipe "apt"
chef.add_recipe "nodejs"
chef.add_recipe "ruby_build"
chef.add_recipe "rbenv::vagrant"
chef.add_recipe "rbenv::user"
chef.add_recipe "vim"
chef.add_recipe "mysql::server"
chef.add_recipe "mysql::client"

# Install Ruby 2.2.1 and Bundler
# Set an empty root password for MySQL to make things simple
chef.json = {
rbenv: {
user_installs: [{
user: 'vagrant',
rubies: ["2.2.1"],
global: "2.2.1",
gems: {
"2.2.1" => [
{ name: "bundler" }
]
}
}]
},
mysql: {
server_root_password: ''
}
}
end
end

Chef 文件

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

cookbook 'apt'
cookbook 'build-essential'
cookbook 'mysql', '5.5.3'
cookbook 'ruby_build'
cookbook 'nodejs'
cookbook 'rbenv', git: 'https://github.com/aminin/chef-rbenv'
cookbook 'vim'

到目前为止,我已经花了 3 天时间整日整夜摆弄这个,但我无法让它工作。我启动了我的 vagrant box,但未安装 bundler ,所以我无法捆绑安装。

显然 chef.json 不工作。我尝试过查看错误输出,我一直在谷歌搜索并打开了数百个选项卡,此时我完全迷路了。

  1. 在我的 chef.json 中,它是如何工作的?我如何开始了解如何制作我自己的 chef.json?看不懂,怎么知道写user_installs之类的?

  2. 下面有区别吗:

a) config.vm.provision :chef_solo do |chef|

b) config.vm.provision "chef solo"do |chef|

  1. 我什至无法用 Google 搜索与 Chef 和 Recipe 相关的任何内容,因为我得到的是食物的 cooking 结果。

最佳答案

哎呀。那里有很多问题..所以我会尝试一次去 1

*) 在本地,您安装的是 chef-client 还是 chef dk?Chefclient 没有 bundler ,而 chefdk 有。这通常也是一种更流畅的体验。

如果您使用的是 chef-client。你必须得到 bundler gem install bundler如果您使用的是 chefdk。您可以将 chefdk ruby​​ 添加到您的路径,使用临时环境设置(eval "$(chef shell-init bash)")或只使用 chef exec bundle ...

*) 半无关。但该博客上的评论可以追溯到 10 多个月前。我建议你看看https://learn.chef.io/index.html获取最新教程

*) chef_solo 和'chef solo' 是不同的东西。 :chef_solo 是一个符号。将其视为 Vagrant 语言中具有特殊含义的事物。 chef solo 没有任何意义 - a) 它里面有一个空格,所以它是两个不同的东西 - 要么是变量(在你的例子中未定义),要么是“chef solo”一个字符串,它有对提供者没有意义。

*) 谷歌搜索 Chef 相关的结果,我建议使用 http://docs.chef.io或包括工具名称“chef vagrant nil error”

最后,为开始学习这个工具集鼓掌。太棒了,但这是一个全新的宇宙。

关于ruby - 使用 Chef 配置构建 Vagrantfile 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29708664/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com