Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vagrant file: host name repeated?

I have following in vagrant config file:

config.vm.define "db01" do |db01|
    db01.vm.box = "geerlingguy/centos7"
    db01.vm.hostname = "db01"
    db01.vm.network "private_network", ip: "192.168.56.15"
    db01.vm.provision "shell", path: "mysql.sh"

What’s the purpose of having "db01" 2 times, once for config.vm.define and once for db01.vm.hostname?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

So the config.vm.define is the name of the virtual machine, while the vm.hostname the hostname that will be assigned to the virtual machine. That hostname is the name that other machines on the network will use to refer to this particular machine while vm name is local kinda label alike. So you do not have them twice really but you are setting two different things but you actually use the same looking string value for both, just because you can and that’s most likely convenient. Yet Still, these are not the same things and not everyone follow that apprach.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading