Vagrant: host manager host name management plug in

I set the host name of the virtual machine. I want to access the host name of the virtual machine on this machine. I can edit the hosts file on this machine manually. A more convenient way is to use the vagant host manager plug-in

Plug in address

https://github.com/devopsgroup-io/vagrant-hostmanager39

Install plug-ins

vagrant plugin install vagrant-hostmanager

Return:

Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.8.2)'!

Using plug-ins

In the vagrantfile, you can add the following configuration for the virtual machine:

  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
  config.hostmanager.manage_guest = true

When defining a virtual machine, you can add a host name to set the host name of the virtual machine

  config.vm.define "node1" do |node1|
    node1.vm.network "private_network", ip: "192.168.33.11"
    node1.vm.hostname="node1"
  end

After starting the virtual machine, the host name of the virtual machine will be automatically updated, and the contents of the hosts file on the local host will also be updated

Or we can manually update and execute the command:

vagrant hostmanager

Return:

[manager1] Updating /etc/hosts file...
[worker1] Updating /etc/hosts file...
[worker2] Updating /etc/hosts file...

Similar Posts: