Thank you Avaro. I created: Make vagrant honor a multi-machine definition in the embedded vagrantfile <https://github.com/hashicorp/vagrant/issues/12268> I am really interested to hear the perspective of development on this.
Frits > Op 3 apr. 2021, om 12:03 heeft Alvaro Miranda Aguilera <[email protected]> > het volgende geschreven: > > Hello > > I dont think this is posible. > > If you create a vagrant file > > and add these 3 lines > > config.vm.define "box1" > config.vm.define "box2" > config.vm.define "box3" > > on the local vagrantfile, the next time you run vagrant status it will show 3 > box > > but if you move those same 3 lines and a config block to the Vagrantfile of > the box > ~/.vagrant.d/boxes/<etc> > > it wont work > > So you could create a github issue with the feature request and see if > development would give hints how to implement this > > Thanks > Alvaro > > > On Sun, Mar 28, 2021 at 12:43 PM Frits Hoogland <[email protected] > <mailto:[email protected]>> wrote: > 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 > <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/ > > <http://127.0.0.1:7100/%5C%5C1centos83-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/ > > <http://127.0.0.1:7100/%5C%5C1centos83-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 > <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 > <https://github.com/hashicorp/vagrant/issues> > Discuss: https://discuss.hashicorp.com/c/vagrant/24 > <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 [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/vagrant-up/9762DE44-6052-4A9F-82D0-7DAFF5FD203D%40gmail.com > > <https://groups.google.com/d/msgid/vagrant-up/9762DE44-6052-4A9F-82D0-7DAFF5FD203D%40gmail.com?utm_medium=email&utm_source=footer>. > >> Op 27 mrt. 2021, om 18:44 heeft Alvaro Miranda Aguilera <[email protected] >> <mailto:[email protected]>> het volgende geschreven: >> >> Hello >> >> Can you share a zip file with code and instructions ? >> >> Thanks >> Alvaro >> >> On Wed, Mar 24, 2021 at 12:03 PM Frits Hoogland <[email protected] >> <mailto:[email protected]>> wrote: >> I am trying to create a vagrant box that launches a cluster of 3 VMs. The >> Vagrantfile to accomplish this works when this definition is in the >> Vagrantfile in the CWD. However, when I move this multi-machine definition >> to the embedded Vagrantfile, vagrant ignores it and creates a default VM, >> ignoring the named machine definitions. >> >> I read the documentation, which doesn’t say anything concrete about this, >> only that multiple Vagrantfiles are merged before starting a vagrant box, >> and that some definitions in the Vagrantfile are added, and some do >> overwrite, which is not very descriptive. >> >> My first question is if this is intended behaviour. >> My second question is if there’s way to make vagrant execute a multi-machine >> setup with the definition in the embedded Vagrantfile, so that a user can >> use a simple default generated Vagrantfile. >> >> >> -- >> This mailing list is governed under the HashiCorp Community Guidelines - >> https://www.hashicorp.com/community-guidelines.html >> <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 >> <https://github.com/hashicorp/vagrant/issues> >> Discuss: https://discuss.hashicorp.com/c/vagrant/24 >> <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 [email protected] >> <mailto:[email protected]>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/vagrant-up/2f2ecef8-a895-4b80-80a1-65aa6dc29f23n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/vagrant-up/2f2ecef8-a895-4b80-80a1-65aa6dc29f23n%40googlegroups.com?utm_medium=email&utm_source=footer>. >> >> >> -- >> Alvaro >> >> >> -- >> This mailing list is governed under the HashiCorp Community Guidelines - >> https://www.hashicorp.com/community-guidelines.html >> <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 >> <https://github.com/hashicorp/vagrant/issues> >> Discuss: https://discuss.hashicorp.com/c/vagrant/24 >> <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 [email protected] >> <mailto:[email protected]>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/vagrant-up/CAHqq0ewm%2BNdY43yfGov2rj1FpHCXLk-4kJ2F_uUJ76LBFHf2Uw%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/vagrant-up/CAHqq0ewm%2BNdY43yfGov2rj1FpHCXLk-4kJ2F_uUJ76LBFHf2Uw%40mail.gmail.com?utm_medium=email&utm_source=footer>. > > > -- > This mailing list is governed under the HashiCorp Community Guidelines - > https://www.hashicorp.com/community-guidelines.html > <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 > <https://github.com/hashicorp/vagrant/issues> > Discuss: https://discuss.hashicorp.com/c/vagrant/24 > <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 [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/vagrant-up/9762DE44-6052-4A9F-82D0-7DAFF5FD203D%40gmail.com > > <https://groups.google.com/d/msgid/vagrant-up/9762DE44-6052-4A9F-82D0-7DAFF5FD203D%40gmail.com?utm_medium=email&utm_source=footer>. > > > -- > Alvaro > > > -- > This mailing list is governed under the HashiCorp Community Guidelines - > https://www.hashicorp.com/community-guidelines.html > <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 > <https://github.com/hashicorp/vagrant/issues> > Discuss: https://discuss.hashicorp.com/c/vagrant/24 > <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 [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/vagrant-up/CAHqq0ez1DHC2ja8LcEd_pxsdDXjogKyM0XipHoJeMa8__b0Saw%40mail.gmail.com > > <https://groups.google.com/d/msgid/vagrant-up/CAHqq0ez1DHC2ja8LcEd_pxsdDXjogKyM0XipHoJeMa8__b0Saw%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/835D8FDA-1F9D-4AE7-9043-4E75FC8FF20A%40gmail.com.
