Vagrant File Chef Attributes

chef-infra, ruby, vagrant

Solution

I'm brand new to Vagrant, Ruby, and Chef, but this is what worked for me:

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

Problem

I am trying to configure my Vagrant file to have some chef attributes, but I must be doing something wrong because the chef recipes are using the defaults instead of my the attributes I am trying to set. Here is my config section of my vagrant file: ``` 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 ``` Is my Ruby wrong or is there a better way to do this?

Original source