How to control the version of Chef that Vagrant uses to provision VMs?

后端 未结 6 1126
眼角桃花
眼角桃花 2020-12-07 08:26

A current Chef recipe isn\'t running because of a bug in version 0.10.10. How can I upgrade the version of Chef that Vagrant uses, to 0.10.12?

I don\'t want to just

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 09:18

    Rebuild the base box. First, bring it up without provisioning and SSH to it.

    vagrant up --no-provision 
    vagrant ssh
    

    Then, perform the commands you need to update the box. This can include updating Chef and Ruby. Optionally, update the packages for the OS, etc. You should clean up the box of everything that isn't required, such as downloaded package files or caches.

    For example, I use the Opscode Omnibus Full Stack Installer for Chef in my Vagrant boxes (originally built with VeeWee), and I update the packages, too.

    sudo dpkg --purge chef chef-full
    sudo true && curl -L https://www.opscode.com/chef/install.sh | sudo bash
    sudo apt-get update && sudo aptitude safe-upgrade
    sudo rm /var/cache/apt/archives/*.deb
    

    Don't forget to "zero" the disk to reduce the size.

    # a bunch of commands like gem install chef, apt-get upgrade, whatever
    sudo dd if=/dev/zero of=/EMPTY bs=1M
    sudo rm /EMPTY
    exit
    

    Then, package the box up and add it to your Vagrant environment for use.

    vagrant package
    vagrant box add mynewlucid32 package.box
    

    If you want to use the same box name, you'll need to remove the existing box (~/.vagrant.d/boxes/BOXNAME) first.

提交回复
热议问题