Hello
Identation is weird, not the problem but hard to read.
your loops also, make it hard to read.
There is some weird character in your v.customize, couldn't find which one.
I did copy and paste one of my files and got past the error, so is
something like a weird tilde or something:
this works:
Vagrant.configure("2") do |config|
HOSTS=5
(1..HOSTS).each do |host_id|
config.vm.box = "centos/7"
config.vm.define "mariadb#{host_id}" do |mariadb|
mariadb.vm.hostname = "mariadb#{host_id}"
mariadb.vm.network "private_network", ip:
"192.168.13.#{1+host_id}"
#mariadb.vm.synced_folder '.', '/vagrant', disabled: true
mariadb.vm.provider "virtualbox" do |v|
v.name = "mariadb#{host_id}"
v.memory = 1024
v.cpus = 1
[ "data", "log" ].each do |volume|
port=2
# MariaDB volumes
file_to_disk = "./mariadb#{host_id}_#{volume}.vdi"
unless File.exist?(file_to_disk)
v.customize ['createhd', '--filename',
"#{file_to_disk}", '--size', (500 * 1024).floor]
end
v.customize ['storageattach', :id, '--storagectl', 'SATA
Controller', '--port', port, '--device', 0, '--type', 'hdd', '--medium',
"#{file_to_disk}"]
port=port+1
end
end
mariadb.vm.provision :shell, path: "bash/bootstrap_avahi.sh",
run: "always"
# All vms have been provisioned. Run Ansible
if host_id == HOSTS
mariadb.vm.provision :ansible do |ansible|
ansible.limit = "all" # Connect to all machines
ansible.playbook = "mariadb.yaml"
ansible.groups = {
"masters" => ["mariadb1", "mariadb2"],
"slaves" => ["mariadb3", "mariadb4", "mariadb5"]
}
#ansible.inventory_path =
".vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory"
end
end
end
end
end
NOTE:
I did add port, since you need to attach each disk on a different port. or
the 2nd disk will fail for port used.
On Mon, Aug 14, 2017 at 2:52 PM, rhys.james.campbell via Vagrant <
[email protected]> wrote:
> Hello All,
>
> I've been trying to figure out how to add a second disk to my Vagrant
> hosts. I receive the following error on vagrant up;
>
> There was an error loading a Vagrantfile. The file being loaded
>> and the error message are shown below. This is usually caused by
>> a syntax error.
>> Path: <provider config: virtualbox>
>> Line number: 17
>> Message: ArgumentError: wrong number of arguments (given 5, expected 1..2)
>
>
>
> Here is my Vagrantfile;
>
>
> Vagrant.configure("2") do |config|
> HOSTS=5
> (1..HOSTS).each do |host_id|
> config.vm.box = "centos/7"
> config.vm.define "mariadb#{host_id}" do |mariadb|
> mariadb.vm.hostname = "mariadb#{host_id}"
> mariadb.vm.network "private_network", ip:
> "192.168.13.#{1+host_id}"
> #mariadb.vm.synced_folder '.', '/vagrant', disabled: true
> mariadb.vm.provider "virtualbox" do |v|
> v.name = "mariadb#{host_id}"
> v.memory = 1024
> v.cpus = 1
> [ "data", "log" ].each do |volume|
> # MariaDB volumes
> file_to_disk = "./mariadb#{host_id}_#{volume}.vdi"
> unless File.exist?(file_to_disk)
> v.customize[ 'createhd',
> '--filename',
> file_to_disk,
> '--size',
> 500 * 1024 ]
> end
> v.customize[ 'storageattach',
> :id,
> '--storagectl',
> 'SATA Controller',
> '--port',
> 1,
> '--device',
> 0,
> '--type',
> 'hdd',
> '--medium',
> file_to_disk ]
> end
> end
> mariadb.vm.provision :shell, path: "bash/bootstrap_avahi.sh",
> run: "always"
> # All vms have been provisioned. Run Ansible
> if host_id == HOSTS
> mariadb.vm.provision :ansible do |ansible|
> ansible.limit = "all" # Connect to all machines
> ansible.playbook = "mariadb.yaml"
> ansible.groups = {
> "masters" => ["mariadb1", "mariadb2"],
> "slaves" => ["mariadb3", "mariadb4", "mariadb5"]
> }
> #ansible.inventory_path = ".vagrant/provisioners/
> ansible/inventory/vagrant_ansible_inventory"
> end
> end
> end
> end
> end
>
> Can anyone tell me what I'm doing wrong. I am using Vagrant 1.9.7 on OS X
> with VirtualBox 5.0.26.
>
>
> --
> 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/601afc0a-0751-458e-aee6-6ec1d40e95b0%40googlegroups.com
> <https://groups.google.com/d/msgid/vagrant-up/601afc0a-0751-458e-aee6-6ec1d40e95b0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Alvaro
--
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/CAHqq0ewxFA48va9ZJ%2B_TU2iXNSZrSQLUkAKMGpRxOHazbPHXDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.