vmware / photon-packer-templates

VMware Photon Packer Templates
Apache License 2.0
35 stars 19 forks source link

non empty /etc/machine-id confuses dhcp server #22

Closed Gankarloo closed 2 years ago

Gankarloo commented 2 years ago

Code of Conduct

Hypervisor

VMware Workstation 16 Pro

Operating System

Windows 10 Version 20H2

HashiCorp Packer

No response

HashiCorp Packer Plugin for VMware

No response

HashiCorp Vagrant

2.2.19

HashiCorp Vagrant VMware Utility

1.0.21

HashiCorp Vagrant plugin for VMware

3.0.1

Environment Details

No response

Description

with a non empty /etc/machine-id all deployed vm's are assigned the same ip address from the internal DHCP server on the VMnet networks.

Expected Behavior

Every deployed vm to get a uniqe DHCP adress

Actual Behavior

VM's get the same DHCP address

Steps to Reproduce

Deploy 2 vm.

  # -*- mode: ruby -*-
  #   # vi: set ft=ruby :
  #
  Vagrant.configure("2") do |config|
    config.vm.box = "vmware/photon"

    config.vm.define "one" do |one|
      one.vm.hostname = "photon1"
    end
    config.vm.define "two" do |two|
      two.vm.hostname = "photon2"
    end
  end

Log Fragments and Files

vagrant up log > Bringing machine 'one' up with 'vmware_desktop' provider... > Bringing machine 'two' up with 'vmware_desktop' provider... > ==> one: Cloning VMware VM: 'vmware/photon'. This can take some time... > ==> one: Checking if box 'vmware/photon' version '4.0.2' is up to date... > ==> one: Verifying vmnet devices are healthy... > ==> one: Preparing network adapters... > ==> one: Fixed port collision for 22 => 2222. Now on port 2205. > ==> one: Starting the VMware VM... > ==> one: Waiting for the VM to receive an address... > ==> one: Forwarding ports... > one: -- 22 => 2205 > ==> one: Waiting for machine to boot. This may take a few minutes... > one: SSH address: 127.0.0.1:2205 > one: SSH username: vagrant > one: SSH auth method: private key > one: Warning: Remote connection disconnect. Retrying... > one: > one: Vagrant insecure key detected. Vagrant will automatically replace > one: this with a newly generated keypair for better security. > one: Warning: Authentication failure. Retrying... > one: Warning: Authentication failure. Retrying... > one: Warning: Authentication failure. Retrying... > one: Warning: Authentication failure. Retrying... > one: Warning: Authentication failure. Retrying... > one: Warning: Remote connection disconnect. Retrying... > ==> one: Machine booted and ready! > ==> one: Setting hostname... > ==> one: Configuring network adapters within the VM... > ==> two: Cloning VMware VM: 'vmware/photon'. This can take some time... > ==> two: Checking if box 'vmware/photon' version '4.0.2' is up to date... > ==> two: Verifying vmnet devices are healthy... > ==> two: Preparing network adapters... > ==> two: Fixed port collision for 22 => 2222. Now on port 2206. > ==> two: Starting the VMware VM... > ==> two: Waiting for the VM to receive an address... > ==> two: Forwarding ports... > two: -- 22 => 2206 > ==> two: Waiting for machine to boot. This may take a few minutes... > two: SSH address: 127.0.0.1:2200 > two: SSH username: vagrant > two: SSH auth method: private key > two: Warning: Remote connection disconnect. Retrying... > two: > two: Vagrant insecure key detected. Vagrant will automatically replace > two: this with a newly generated keypair for better security. > two: > two: Inserting generated public key within guest... > two: Removing insecure key from the guest if it's present... > two: Key inserted! Disconnecting and reconnecting using new SSH key... > ==> two: Machine booted and ready! > ==> two: Setting hostname... > ==> two: Configuring network adapters within the VM...

Screenshots

VM 1

image

VM 2

image

Additional Context

I made a modified box based on the vmware/photon 4.0.2 where the only modification was to delete the file /etc/machine-id that box works as expected.

Screenshots of 3 working VM's ## VM 1 ![image](https://user-images.githubusercontent.com/12395912/155217365-09c8190b-a5dd-4a1f-b329-a2268ccded5f.png) ## VM 2 ![image](https://user-images.githubusercontent.com/12395912/155217409-e6ed9473-56c7-4edd-8cea-0c5878eaf768.png) ## VM 3 ![image](https://user-images.githubusercontent.com/12395912/155217462-021c49bc-e02d-4682-ae75-3eb490094f72.png)
tenthirtyam commented 2 years ago

Can you test by adding the following to complete-build.sh?

truncate -s 0 /etc/machine-id
rm /var/lib/dbus/machine-id
ln -s /etc/machine-id /var/lib/dbus/machine-id

Ryan

Gankarloo commented 2 years ago

That did the trick. With those 3 lines all vm's from the new box gets different addresses.

tenthirtyam commented 2 years ago

I'll merge this in soon. :)