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?
>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.