Hi Alvaro! Thank you for taking the time and effort to look into this. I got a 'box' here: https://app.vagrantup.com/FritsHoogland/boxes/centos8-yb-rf3 This box is meant to start up 3 virtual machines using vagrant. The Vagrantfile that is created as part of init in the user current working directory essentially just points to the vagrant box, I don't believe there is a way to add content to that Vagrantfile automatically. The embedded Vagrantfile is attached. The essence of the embedded Vagrantfile is to set variables, which can be modified by setting environment variables, after which there is a loop based on the variable replication_factor, which I put below: Vagrant.configure("2") do |config| # all the nodes use an identical image. config.vm.box = "FritsHoogland/centos8-yb-rf3" # we use the same number of nodes as the replication factor. # for RF=3, we need 3 yb-master processes, for which we create a VM each. # each VM runs a yb-tserver process too, for which the number can be higher. (1..replication_factor.to_i).each do |vm_nr| config.vm.define "centos83-yb-#{vm_nr}" do |subconfig| subconfig.vm.hostname = "centos83-yb-#{vm_nr}.local" if ip_address[vm_nr] != 'no' subconfig.vm.network :private_network, ip: ip_address[vm_nr] end subconfig.vm.provider :virtualbox do |vb| vb.memory = memory_size vb.cpus = nr_cpus if add_disk == 'yes' data1_disk = "data1_vm#{vm_nr}.vdi" if !File.exist?(data1_disk) vb.customize [ 'createhd', '--filename', data1_disk, '--size', disk_size ] end vb.customize [ 'storageattach', :id, '--storagectl', 'SATA Controller', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', data1_disk ] end end if replication_factor == "3" subconfig.vm.provision "master.conf:master_addresses", type: "shell", privileged: true, inline: "sed -i 's/\\(--master_addresses=\\)127.0.0.1:7100/\\1centos83-yb-1.local:7100,centos83-yb-2.local:7100,centos83-yb-3.local:7100/' /home/yb/master.conf" subconfig.vm.provision "master.conf:replication_factor", type: "shell", privileged: true, inline: "sed -i 's/\\(--replication_factor=\\)1/\\13/' /home/yb/master.conf" subconfig.vm.provision "tserver.conf:tserver_master_addrs", type: "shell", privileged: true, inline: "sed -i 's/\\(--tserver_master_addrs=\\)127.0.0.1:7100/\\1centos83-yb-1.local:7100,centos83-yb-2.local:7100,centos83-yb-3.local:7100/' /home/yb/tserver.conf" subconfig.vm.provision "etc_hosts", type: "shell", privileged: true, inline: add_hostnames_to_etc_hosts end # provisioning # if we find a blockdevice /dev/sdb, a disk is attached. subconfig.vm.provision "setup /dev/sdb", type: "shell", privileged: true, inline: partition_and_format if start_services == 'yes' subconfig.vm.provision "enable yb-master service", type: "shell", privileged: true, inline: "systemctl enable yb-master" subconfig.vm.provision "start yb-master service", type: "shell", privileged: true, inline: "systemctl start yb-master" subconfig.vm.provision "enable yb-tserver service", type: "shell", privileged: true, inline: "systemctl enable yb-tserver" subconfig.vm.provision "start yb-tserver service", type: "shell", privileged: true, inline: "systemctl start yb-tserver" end end end end This loop seems to be totally ignored when it's in the embedded Vagrantfile. Currently, I am letting the users of this box copy the embedded Vagrantfile over the 'user vagrant file', after which it does get executed, and creates 3 nodes (the default value of replication_factor). However, it would be great if I can do the heavy lifting like above in the embedded Vagrantfile, so the user is not bothered by all these details, and can just init a simple Vagrantfile and start it. So the question is how to make constructions like above actually be executed in the embedded Vagrantfile? Thank you, Frits
-- 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/hashicorp/vagrant/issues Discuss: https://discuss.hashicorp.com/c/vagrant/24 --- 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 vagrant-up+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/9762DE44-6052-4A9F-82D0-7DAFF5FD203D%40gmail.com. |
Vagrantfile
Description: Binary data
-- 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/hashicorp/vagrant/issues Discuss: https://discuss.hashicorp.com/c/vagrant/24 --- 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 vagrant-up+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/9762DE44-6052-4A9F-82D0-7DAFF5FD203D%40gmail.com. |