hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.27k stars 4.43k forks source link

Chef + Windows VM tries to install chef using apt-get #5327

Closed spuder closed 9 years ago

spuder commented 9 years ago

If you spin up a windows VM, and you try and use the chef_solo provisioner. Vagrant, will attempt to install chef for you, however it will do that using 'apt-get'

Vagrant file

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

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(2) do |config|
  config.vm.box = "lmayorga1980/windows-2012r2"
  config.vm.communicator = "winrm"
  config.vm.network "forwarded_port", host: 3389, guest: 3389
  config.vm.provider "virtualbox" do |v|
    v.cpus = 2
    v.memory = 2048
  end

  # Provisioning
  config.vm.provision "chef_solo" do |chef|
    chef.add_recipe "example-Webserver2012"
  end
end
sowens-MBP:example-Webserver2012 sowen$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
    default: The Berkshelf shelf is at "/Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150211-3256-mhpte3-default"
==> default: Sharing cookbooks with VM
# -*- mode: ruby -*-
==> default: Importing base box 'lmayorga1980/windows-2012r2'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'lmayorga1980/windows-2012r2' is up to date...
==> default: Setting the name of the VM: example-Webserver2012_default_1423673882548_97092
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Fetching 'example-Webserver2012' from source at .
==> default: Using example-Webserver2012 (0.1.0) from source at .
==> default: Using iis (2.1.6)
==> default: Using windows (1.36.1)
==> default: Using chef_handler (1.1.6)
==> default: Vendoring ND-Webserver2012 (0.1.0) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150211-3256-mhpte3-default/ND-Webserver2012
==> default: Vendoring chef_handler (1.1.6) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150211-3256-mhpte3-default/chef_handler
==> default: Vendoring iis (2.1.6) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150211-3256-mhpte3-default/iis
==> default: Vendoring windows (1.36.1) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150211-3256-mhpte3-default/windows
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 3389 => 3389 (adapter 1)
    default: 5985 => 55985 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /Users/sowen/Devops/vagrant-windows/ND-Webserver2012

^C==> default: Waiting for cleanup before exiting...

^C==> default: Exiting immediately, without cleanup!
sowens-MBP:ND-Webserver2012 sowen$ vagrant provision
==> default: Loading Berkshelf datafile...
==> default: Sharing cookbooks with VM
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Fetching 'ND-Webserver2012' from source at .
==> default: Using ND-Webserver2012 (0.1.0) from source at .
==> default: Using chef_handler (1.1.6)
==> default: Using iis (2.1.6)
==> default: Using windows (1.36.1)
==> default: Vendoring ND-Webserver2012 (0.1.0) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150211-3256-mhpte3-default/ND-Webserver2012
==> default: Vendoring chef_handler (1.1.6) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150211-3256-mhpte3-default/chef_handler
==> default: Vendoring iis (2.1.6) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150211-3256-mhpte3-default/iis
==> default: Vendoring windows (1.36.1) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150211-3256-mhpte3-default/windows
==> default: Running provisioner: chef_solo...
    default: Installing Chef (latest)...
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

apt-get update -y -qq
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }

Stdout from the command:

Stderr from the command:

#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">apt-get : The term 'apt-get' is not recognized as the name of a cmdlet, _x000D__x000A_</S><S S="Error">function, script file, or operable program. Check the spelling of the name, or _x000D__x000A_</S><S S="Error">if a path was included, verify that the path is correct and try again._x000D__x000A_</S><S S="Error">At line:1 char:1_x000D__x000A_</S><S S="Error">+ apt-get update -y -qq_x000D__x000A_</S><S S="Error">+ ~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : ObjectNotFound: (apt-get:String) [], CommandNotF _x000D__x000A_</S><S S="Error">   oundException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>

I've tried setting config.vm.guest = :windows however the problem persists. I think this is a bug in vagrant.

spuder commented 9 years ago

I can't reproduce this. I done vagrant destroy and vagrant up multiple times. The first few times the problem was consistent, now it has gone away.

config.vm.guest = :windows is required.