How do I configure Chef Solo to install Nginx on a new Vagrant box? How do I configure Chef Solo to install Nginx on a new Vagrant box? nginx nginx

How do I configure Chef Solo to install Nginx on a new Vagrant box?


To more effectively use chef I'd advise installing the following vagrant plugins:

vagrant plugin install vagrant-omnibusvagrant plugin install vagrant-berkshelf

Berkshelf is a tool for managing cookbook dependencies. The omnibus plugin is useful to ensure you're using the latest revision of chef.

The following example demonstrates how easy it becomes to install something like nginx.

Example

├── Berksfile└── Vagrantfile

Berkshelf

Lists the required cookbooks. Berkshelf will download them (and dependencies) from the opscode community website.

site :opscodecookbook "nginx"

Vagrantfile

The following vagrant file will install nginx, making it available on port 8080 of the host machine:

Vagrant.configure("2") do |config|  # Box details  config.vm.box = "Berkshelf-CentOS-6.3-x86_64-minimal"  config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box"  # Plugins  config.berkshelf.enabled = true  config.omnibus.chef_version = :latest  # Network  config.vm.network :forwarded_port, guest: 80, host: 8080  # Chef solo provisioning  config.vm.provision :chef_solo do |chef|    chef.add_recipe "nginx"  endend

Notes:

  • This example uses CentOS. Should work equally well on Ubuntu.


Hi I got into same problem and while searching stumbled upon your issue. I have solved it wi simple including APT recipe. Reason why you need it because you have to to apt-get update on the new instance before you can install packages. thats all.