hashicorp / vagrant

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

Vagrant Salt Re-installs on Every Provision #10531

Closed jalandis closed 1 year ago

jalandis commented 5 years ago

Short Description Every call to vagrant provision reinstalls the salt minion on the Windows guest.

Versions Vagrant version: 2.2.2 Host: Ubuntu 18.04 Guest: Windows Server 2012 R2 Standard

Possible Cause The Salt provisioner uses the which command to determine if necessary binaries are installed in order to determine if the bootstrap script should be executed. This is not available for Windows.

https://github.com/hashicorp/vagrant/blob/a4d5ee6ac1aa88d827fc05e2ba85a90bc40ba004/plugins/provisioners/salt/provisioner.rb#L80

Vagrantfile

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

Vagrant.configure("2") do |config|

  config.vagrant.plugins = [
      "vagrant-hostmanager",
      "vagrant-vbguest"
  ]

  config.windows.halt_timeout = 15
  config.winrm.username = "vagrant"
  config.winrm.password = "vagrant"
  config.winrm.port = 5989
  config.winrm.timeout = 60 * 60 * 10 # 10 hours
  config.winrm.max_tries = 100
  config.vm.boot_timeout = 60 * 15 # 15 minutes

  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
  config.hostmanager.ignore_private_ip = false
  config.hostmanager.include_offline = true

  # Windows VM Config
  windows_hostname = 'saltDev'
  config.vm.define windows_hostname, primary: true do |windows|

    windows.vbguest.auto_update = false

    windows.vm.provider "virtualbox" do |v|
      v.name = windows_hostname
      v.cpus = 1
      v.memory = 4096
    end

    windows.vm.box = "devopsgroup-io/windows_server-2012r2-standard-amd64-nocm"
    windows.vm.provision :hostmanager

    windows.vm.synced_folder "./", "/vagrant", disabled: true
    windows.vm.synced_folder "../", "/workspace"

    windows.vm.network :private_network, ip: "10.98.76.30"

    windows.vm.provision :salt do |salt|
      salt.install_args = "-runservice false"
      salt.masterless = true
      salt.verbose = true
      salt.minion_config = "minion"
      salt.run_highstate = true
    end

    windows.vm.communicator = "winrm"
    windows.vm.hostname = windows_hostname
  end
end

Results of a provision with Salt already installed

Copying salt minion config to vm.
Checking if C:\salt\salt-minion.bat is installed
C:\salt\salt-minion.bat was not found.
Checking if C:\salt\salt-call.bat is installed
C:\salt\salt-call.bat was not found.
Using Bootstrap Options: 
Bootstrapping Salt... (this may take a while)
Service defaulting to run.
Downloading Salt minion installer Salt-Minion-2017.7.1-Py2-AMD64-Setup.exe
Installing Salt minion...
jalandis commented 5 years ago

I switched which to dir and I am using that as a work around for now.

muddman commented 5 years ago

Is there a temporary fix I can use to keep it from reinstalling with each provision?