Hi all,

I'm looking to make my vagrant file idempotent and almost have it. 
 However, when I run *vagrant up --provision* on a machine that has already 
been created, I get an error about my SATA storage controller.  To avoid 
this, I have to manually delete the controller in Virtualbox and run the 
command again.  Removing my SATA controller is ok because it is only used 
to host ISO files that I am accessing directly to install some software.

Is this even possible?  I'd like to make my provision a little smarter in 
case I have to force provision an already created machine.  Here's my 
provider config below:

config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    
    # Customize the amount of memory on the VM:
    vb.memory = 4096
    
    # Customize the amount of CPUs the VM will use:
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--vram", "128"]
    vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
    # Customize additional Virtualbox settings
    vb.customize ["sharedfolder", "add", :id, "--name", "VM_Share", 
"--hostpath", "path/to/share/folder/", "--automount"]


    #below commented SATA customize will only work when the VM has already 
been created...on a fresh run this will error since the SATA controller 
does not exist
    #vb.customize ["storagectl", :id, "--name", "SATA", "--remove" ]
    vb.customize ["storagectl", :id, "--name", "SATA", "--add", "sata" ]


    # Add an ISO file here
    vb.customize ["storageattach", :id, "--storagectl", "SATA", "--port", 
"0", "--device", "0", "--type", "dvddrive", "--medium", "path/to/file.iso"]


    # Add another ISO file here
    vb.customize ["storageattach", :id, "--storagectl", "SATA", "--port", 
"1", "--device", "0", "--type", "dvddrive", "--medium", "path/to/file.iso"]
  end

Thanks in advance,

Christopher

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/890ada33-53a2-4950-bdf9-72c951193c32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to