I'm using Chef Solo to provision a Vagrant VM based on Opscode's "Bento" box for Ubuntu 12.04. When it's done provisioning and I SSH in for the first time, the MOTD tells me there are packages and security updates. I then run sudo apt-get upgrade manually, which removes the message on subsequent logins. Is there a way to automate this step with Chef? The "apt" cookbook doesn't seem to handle this. All my Google searches find things only about apt-get update but not apt-get upgrade. I could just execute the apt-get command in my Chef recipe, but during the upgrade process, there is a pseudo-GUI on a pink screen where I have to select drives for installation (I think this is called GRUB, I'm new to Ubuntu) and I'm not sure how this part can be automated with Chef.

3 Answers
3

I just encountered this exact issue myself with chef+vagrant and found the following worked for me:

sudo dpkg-reconfigure -plow grub-pc

This allows you to reconfigure grub-pc and select the device (if any) you want grub installed on. Setting a device as default here should allow an upgrade that includes grub to not prompt for a device selection. At this point you could create a new vagrant box and use that as your default.

or

To run an apt-get upgrade/dist-upgrade without being prompted you could use:

That command took me through a similar series of pink GRUB screens, including the same device selection I encounter when running apt-get upgrade. :|
–
Jimmy CuadraFeb 27 '13 at 1:45

Well as I explained in my answer that is what it should do. It allows you to run an apt-get upgrade from that point on without a prompt. You could bundle it up and create a new vagrant base box at this point. Modifying my answer to give you a better alternative.
–
dokFeb 27 '13 at 10:45

Vagrant runs Chef Solo automatically when building the VM, so I'm not sure how I would run the upgrade "before" the Chef run. I tried just running the command with -y inside my main recipe, and it seemed to be processing fine, but then (presumably when it got to the GRUB part), it spat out a bunch of random characters to my shell and killed the whole Vagrant process.
–
Jimmy CuadraFeb 17 '13 at 5:40

Using the -y parameter does not help with the GRUB interface.
–
MariusJan 28 at 13:02