Vagrant File Chef属性

时间:2012-04-04 17:42:22

标签: ruby chef vagrant

我正在尝试将我的Vagrant文​​件配置为具有一些厨师属性,但我必须做错事,因为厨师食谱使用默认值而不是我尝试设置的属性。这是我的流浪文件的配置部分:

config.vm.provision :chef_solo do |chef|
    chef.json = {
      :mysql => {
        :server_root_password => 'password'
      },
      :nodejs => {
        :version => '0.6.14',
        :dir => '/usr/local',
        :npm => '1.1.13'
      }
    }
    chef.cookbooks_path = "config/env/cookbooks"
    chef.add_recipe "apt"
    chef.add_recipe "mongodb::10gen_repo"
    chef.add_recipe "mongodb"
    chef.add_recipe "mysql::client"
    chef.add_recipe "mysql::server"
    chef.add_recipe "nodejs"
    chef.add_recipe "nodejs::npm"
    #chef.add_recipe "mymc_service"

end

我的Ruby是错的还是有更好的方法来做到这一点?

2 个答案:

答案 0 :(得分:21)

我是Vagrant,Ruby和Chef的新手,但这对我有用:

config.vm.provision :chef_solo do |chef|
    chef.json = {
        "mysql" => {
            "server_root_password" => "password"
        }
    }
    chef.add_recipe "mysql" # etc
end

答案 1 :(得分:3)

我最近遇到了同样的问题。虽然Mike的答案并没有解决我的问题,可能是由于较新的Vagrant / Chef版本,但它指出了我正确的方向。以下是我必须要做的MySQL服务器工作:

config.vm.provision :chef_solo do |chef|
    chef.json = {
        :mysql => {
            :server_root_password => "password",
            :server_repl_password => "password",
            :server_debian_password => "password"
        }
    }
    chef.add_recipe "mysql::server"
end