{"action":"closed","issue":{"url":"https://api.github.com/repos/mitchellh/vagrant/issues/5250","labels_url":"https://api.github.com/repos/mitchellh/vagrant/issues/5250/labels{/name}","comments_url":"https://api.github.com/repos/mitchellh/vagrant/issues/5250/comments","events_url":"https://api.github.com/repos/mitchellh/vagrant/issues/5250/events","html_url":"https://github.com/mitchellh/vagrant/issues/5250","id":55554303,"number":5250,"title":"Ordering issue: extra disk attached before VM exists","user":{"login":"carroarmato0","id":1828645,"avatar_url":"https://avatars.githubusercontent.com/u/1828645?v=3","gravatar_id":"","url":"https://api.github.com/users/carroarmato0","html_url":"https://github.com/carroarmato0","followers_url":"https://api.github.com/users/carroarmato0/followers","following_url":"https://api.github.com/users/carroarmato0/following{/other_user}","gists_url":"https://api.github.com/users/carroarmato0/gists{/gist_id}","starred_url":"https://api.github.com/users/carroarmato0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carroarmato0/subscriptions","organizations_url":"https://api.github.com/users/carroarmato0/orgs","repos_url":"https://api.github.com/users/carroarmato0/repos","events_url":"https://api.github.com/users/carroarmato0/events{/privacy}","received_events_url":"https://api.github.com/users/carroarmato0/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-26T23:39:50Z","updated_at":"2015-02-24T19:19:31Z","closed_at":"2015-02-24T19:19:31Z","body":"I have a situation where I'd like 2 \"storage\" vagrant boxes to have for each, an extra disk created and attached with Virtualbox.\r\n\r\nThis works for 1 VM, but with multiple ones it's different:\r\n\r\n<pre>\r\n  storage01_extra_disk = '/tmp/storage01_extra_disk.vdi'\r\n  storage02_extra_disk = '/tmp/storage02_extra_disk.vdi'\r\n\r\n  config.vm.define \"storage01\" do |storage01|\r\n    storage01.vm.provider \"virtualbox\" do |v|\r\n      v.name = 'gluster-storage01'\r\n    end\r\n    storage01.vm.hostname = \"storage01\"\r\n    storage01.vm.network \"private_network\", ip: \"192.168.33.11\"\r\n  end\r\n\r\n  config.vm.define \"storage02\" do |storage02|\r\n    storage02.vm.provider \"virtualbox\" do |v|\r\n      v.name = 'gluster-storage02'\r\n    end\r\n    storage02.vm.hostname = \"storage02\"\r\n    storage02.vm.network \"private_network\", ip: \"192.168.33.12\"\r\n  end\r\n\r\n  ## Create and/or attach a secondary disk to be used for data in Gluster\r\n  config.vm.provider \"virtualbox\" do |v|\r\n\r\n    unless File.exist?(storage01_extra_disk)\r\n      v.customize ['createhd', '--filename', storage01_extra_disk, '--size', 500 * 1024]\r\n    end\r\n    v.customize ['storageattach', 'gluster-storage01', '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', storage01_extra_disk]\r\n\r\n    unless File.exist?(storage02_extra_disk)\r\n      v.customize ['createhd', '--filename', storage02_extra_disk, '--size', 500 * 1024]\r\n    end\r\n    v.customize ['storageattach', 'gluster-storage02', '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', storage02_extra_disk]\r\n\r\n  end\r\n</pre>\r\n\r\nThis gives me the following issue:\r\n\r\n<pre>\r\n[carroarmato0:~/Work/Vagrant/Gluster] master(+28/-4) ± vagrant up \r\nBringing machine 'storage01' up with 'virtualbox' provider...\r\nBringing machine 'storage02' up with 'virtualbox' provider...\r\nBringing machine 'client01' up with 'virtualbox' provider...\r\nBringing machine 'client02' up with 'virtualbox' provider...\r\n==> storage01: Importing base box 'https://dumps.carroarmato0.be/vagrantboxes/centos-6.6-64b-puppet-vbox.box'...\r\n==> storage01: Matching MAC address for NAT networking...\r\n==> storage01: Setting the name of the VM: gluster-storage01\r\n==> storage01: Clearing any previously set network interfaces...\r\n==> storage01: Preparing network interfaces based on configuration...\r\n    storage01: Adapter 1: nat\r\n    storage01: Adapter 2: hostonly\r\n==> storage01: Forwarding ports...\r\n    storage01: 22 => 2222 (adapter 1)\r\n==> storage01: Running 'pre-boot' VM customizations...\r\nA customization command failed:\r\n\r\n[\"storageattach\", \"gluster-storage02\", \"--storagectl\", \"IDE Controller\", \"--port\", 1, \"--device\", 0, \"--type\", \"hdd\", \"--medium\", \"/tmp/storage02_extra_disk.vdi\"]\r\n\r\nThe following error was experienced:\r\n\r\n#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant\r\nfor controlling VirtualBox. The command and stderr is shown below.\r\n\r\nCommand: [\"storageattach\", \"gluster-storage02\", \"--storagectl\", \"IDE Controller\", \"--port\", \"1\", \"--device\", \"0\", \"--type\", \"hdd\", \"--medium\", \"/tmp/storage02_extra_disk.vdi\"]\r\n\r\nStderr: VBoxManage: error: Could not find a registered machine named 'gluster-storage02'\r\nVBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBox, interface IVirtualBox, callee nsISupports\r\nVBoxManage: error: Context: \"FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())\" at line 313 of file VBoxManageStorageController.cpp\r\n>\r\n\r\nPlease fix this customization and try again.\r\n</pre>\r\n\r\nIt looks like right after the first VM is created, it calls the virtualbox customize stanza's, but doesn't stop with the first one.\r\n\r\nI think it would be possible to fix this by having a conditional to see if the stanza is called within the context of a certain VM, excluding the none relevant sections.\r\n\r\nSomething like:\r\n\r\n<pre>\r\nunless v.name == 'gluster-storage01'\r\n</pre>\r\n\r\nAny idea?"}}