sous-chefs / vagrant

Development repository for the vagrant cookbook
https://supermarket.chef.io/cookbooks/vagrant
Apache License 2.0
57 stars 52 forks source link

Install on macOS doesn't work if any version of Vagrant is already installed #96

Closed brownmike closed 6 years ago

brownmike commented 6 years ago

Cookbook version

0.9.1

Chef-client version

14.4.56

Platform Details

macOS 10.13.6

Scenario

I'm attempting to upgrade the version of Vagrant installed on the nodes. I was surprised to see that bumping the version number of default['vagrant']['version'] did nothing.

Steps to Reproduce

My attributes file:

default['vagrant']['version'] = '2.1.4'
default['vagrant']['checksum'] = 'aa097c786bbda33bfe39999a8c353715afe591b593d9a9e5ae422160d3689ae9'
default['vagrant']['url'] = 'https://releases.hashicorp.com/vagrant/2.1.4/vagrant_2.1.4_x86_64.dmg'

My default recipe:

include_recipe 'vagrant::default'

The node I'm running this on is currently running vagrant 2.1.1

Expected Result

I expect vagrant 2.1.4 to be installed

Actual Result

Recipe: vagrant::default
  * vagrant[Vagrant] action install[2018-09-12T15:14:03-07:00] INFO: Processing vagrant[Vagrant] action install (vagrant::default line 18)
[2018-09-12T15:14:03-07:00] INFO: Processing vagrant[Vagrant] action install (vagrant::default line 18)

    * dmg_package[Vagrant] action install[2018-09-12T15:14:03-07:00] INFO: Processing dmg_package[Vagrant] action install (/var/chef/cache/cookbooks/vagrant/resources/default.rb line 41)
[2018-09-12T15:14:03-07:00] INFO: Processing dmg_package[Vagrant] action install (/var/chef/cache/cookbooks/vagrant/resources/default.rb line 41)
[2018-09-12T15:14:03-07:00] INFO: Already installed; to upgrade, try "sudo pkgutil --forget 'com.vagrant.vagrant'"
[2018-09-12T15:14:03-07:00] INFO: Already installed; to upgrade, try "sudo pkgutil --forget 'com.vagrant.vagrant'"
 (up to date)
     (up to date)

And the version is not updated

$ ❯❯❯ vagrant --version
Vagrant 2.1.1

Analysis

It looks like the underlying implementation for macOS does not utilize the mechanism for comparing the current running version of vagrant to the requested version.

damacus commented 6 years ago

That certainly seems like a bug.

If you want to open a our to help this fix, that'd be great!

I imagine this cookbook is going to get refactored into custom resources soon, so that should help

MarkGibbons commented 6 years ago

Taking a look.

MarkGibbons commented 6 years ago

@brownmike

What I see going on is that the vagrant cookbook only supports the :install option. :install for packages is usually distinct from :upgrade. For Installing packages on a mac the vagrant cookbook uses the dmg_package resource which doesn't support :upgrade. So, it's not a bug, the cookbook is acting as expected. :upgrade isn't the default or even a supported option.

It doesn't look horrible to add some code to this cookbook to uninstall vagrant and then install it on a mac. The problems come in with supporting upgrade for all the platforms involved. Upgrade would be sort of nasty, I think, on Windows with the reboots needed.

I'll close this issue in a couple days. If you have a strong need for an upgrade capability we'll accept a PR or an issue requesting the feature. The cookbook doesn't really have a delete or an upgrade action for the vagrant package at the moment. Both actions would be nice, time though.

Thanks, Mark

brownmike commented 6 years ago

@MarkGibbons Thanks for the detailed response. Feel free to close this out, I can add some handling in my cookbook for this situation. If it seems generic enough, I may open a PR; but we'll see :)

MarkGibbons commented 6 years ago

Closing. A delete and/or upgrade option seems like an obvious extension to make.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.