Hello All,
I am having trouble with one of my machines getting shell scripts to run only when a specifici provider is selected. For example here is a simplified machine:
config.vm.define "analyzer" do |analyzer|
analyzer.vm.box = "centos/8"
analyzer.vm.box_version = "1905.1"
analyzer.vm.provider "virtualbox" do |v, override|
v.memory = 2048
v.cpus = 2
v.customize ["modifyvm", :id, "--vram", "256"]
v.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
v.customize ["modifyvm", :id, "--accelerate3d", "on"]
v.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
end
analyzer.vm.synced_folder ".", "/vagrant", disabled: true
analyzer.vm.network "private_network", ip: "192.168.70.20"
analyzer.vm.provider "virtualbox" do |vb|
analyzer.vm.provision "shell", inline: "echo Inside virtualbox Conditional"
end
analyzer.vm.provider "vmware_desktop" do |vmd|
analyzer.vm.provision "shell", inline: "echo Inside vmware_desktop Conditional"
end
analyzer.vm.provider "vmware_esxi" do |vme|
analyzer.vm.provision "shell", inline: "echo Inside vmware_esxi Conditional"
end
end
What I thought would happen was if I ran vagrant up using --provider=virtualbox, only the echo for the virtualbox would trigger. But that does not seem to be how it works. I am getting all of them triggering multiple times.
==> analyzer: Configuring and enabling network interfaces...
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside virtualbox Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_desktop Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_esxi Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside virtualbox Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_desktop Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_esxi Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside virtualbox Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_desktop Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_esxi Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside virtualbox Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_desktop Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_esxi Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside virtualbox Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_desktop Conditional
==> analyzer: Running provisioner: shell...
analyzer: Running: inline script
analyzer: Inside vmware_esxi Conditional
Am I doing something wrong? Any help would be appreciated.
Thank you.