Question

Using vagrant + Berkshelf, I'm trying to update my already existing VM to a newer git version.

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "centos_64" # CentOS 6.5 box

  config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box"        # URL of the `centos_64` box

  config.berkshelf.enabled = true  # use Berkshelf
  config.omnibus.chef_version = :latest     # install chef

  config.vm.provider "virtualbox" do |vb|
     vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] # speed up networking on guest
     vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]        # ditto
       vb.memory = 1024                                              # 1 GB RAM for guest VM
       vb.customize ["modifyvm", :id, "--cpuexecutioncap", "75"]     # 75% of CPU goes to host VM.
  end
end

Berksfile

cookbook 'git', '>= 1.9.0'

Note that I added the version constraint after the VM was created.

However, when running vagrant reload --version, no software update was made to the git version.

Additionally, destroying the VM, and then running vagrant up --provision does not result in installing the v 1.9.0 (or better) version of git.

Why's that?

Was it helpful?

Solution

If you want version 1.9.1 of git installed, you will need to have something like this in your vagrant file:

config.vm.provision :chef_solo do |chef|
    chef.json = {
      "git" => {
        "version" => "1.9.1",
        "checksum" => "8e300c0b72c2738ca273c38ea9566d5326d554f8bb5f4d6aa40c87783edcd153"
      }
    }
    chef.add_recipe "git::source"
end

Where version is the version of git you want to download (this will become "https://nodeload.github.com/git/git/tar.gz/v1.9.1")

checksum is a sha256sum of the downloaded file to verify the contents

chef.add_recipe "git::source" will install git from source (the downloaded file above) as opposed to getting it from yum or apt or whatever package manager your distro is using.

Git 1.9.1 will be installed to /usr/local but if you have already got git installed in /usr/bin then you may need to uninstall that first.

OTHER TIPS

You're missing a provisioner:

config.vm.provision :chef_solo do |chef|
  chef.add_recipe "git"
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top