chrismanderson
chrismanderson

Reputation: 4813

Vagrantfile not respecting nginx version using Chef for provisioning

Getting started with using Vagrant for some Rails development. Going one step at a time, so I'm first trying to install nginx via a Chef recipe in the vagrant file. However, while I set the nginx version in the Vagrantfile to 1.20.0, Vagrant does not seem to recognize it and keeps installing version 1.1.19.

I'm going to go through all my steps to make sure I'm not missing anything.

I've got a directory structure of:

--vagrant_boxes
  --cookbooks
  --vagrant_box1

I downloaded the nginx cookbook from opscode via knife.

knife cookbook site install nginx

This installed nginx and its dependencies into my cookbooks directory.

I then created a new box in vagrant_box1

vagrant init precise64

and edited the Vagrant file to read

config.vm.provision :chef_solo do |chef|
  chef.cookbooks_path = "../cookbooks"
  chef.add_recipe "nginx"
  chef.json = { :nginx => { :version => "1.2.0" } }
end

I ran vagrant up, and then vagrant ssh.

And in the Vagrant box, nginx -v gave me nginx version: nginx/1.1.19. Which is not what I want. I want to understand Vagrant and chef, so any assistance would be greatly appreciated!

Upvotes: 1

Views: 710

Answers (1)

turtlebender
turtlebender

Reputation: 1907

IIRC the version attribute only applies to the nginx::source recipe. So instead of:

chef.add_recipe "nginx"

try:

chef.add_recipe "nginx::source"

Then the correct version should be installed

Upvotes: 4

Related Questions