Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant File Chef Attributes

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?

like image 855
Clint Avatar asked Apr 04 '12 17:04

Clint


People also ask

What is Chef_zero?

Chef Zero is a simple, easy-install, in-memory Chef server that can be useful for Chef Client testing and chef-solo-like tasks that require a full Chef Server. It IS intended to be simple, Chef 11+ compliant, easy to run and fast to start. It is NOT intended to be secure, scalable, performant or persistent.

What does Vagrant provision do?

Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine as part of the vagrant up process. This is useful since boxes typically are not built perfectly for your use case.

What is puppet vagrant?

Provisioner name: puppet The Vagrant Puppet provisioner allows you to provision the guest using Puppet, specifically by calling puppet apply , without a Puppet Master. Warning: If you are not familiar with Puppet and Vagrant already, it is recommended to start with the shell provisioner.


1 Answers

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
like image 152
Mike Branski Avatar answered Sep 28 '22 03:09

Mike Branski