Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dhcp ip changed : no SSH after reboot [vsphere-iso] #10893

Closed
necarnot opened this issue Apr 9, 2021 · 2 comments
Closed

dhcp ip changed : no SSH after reboot [vsphere-iso] #10893

necarnot opened this issue Apr 9, 2021 · 2 comments

Comments

@necarnot
Copy link

necarnot commented Apr 9, 2021

Overview of the Issue

Packer 1.7.2 fails to connect via SSH during the installation of an Ubuntu 20.04.2 live server because the ip of the guest changes after the first reboot, and the DHCP provides a different ip address. Packer still uses the first seen ip address.

In #8528 , it's claimed that this point is fixed for vmware-iso, but I'm witnessing that with vsphere-iso, the issue remains.

Reproduction Steps

  • Use packer 1.7.2 with vsphere-iso
  • Set up a deployment of an Ubuntu 20.04.2 live server (thus, not the legacy one)
  • The installation looks good, but the logs are showing Packer forever failing to connect via SSH because targetting the wrong previous ip address.

Packer version

1.7.2

Buildfile

build {
  sources = [
    "source.vsphere-iso.ubuntu20_04_varnames"
  ]

  provisioner "shell" {
    inline = ["echo 'Packer Template Build -- Complete'"]
  }
}

sources_ubuntu_20_04.pkr.hcl

source "vsphere-iso" "ubuntu20_04_varnames" {
  vcenter_server       = "${var.vcenter_server}"
  username             = "${var.vcenter_username}"
  password             = "${var.vcenter_password}"
  cluster              = "${var.cluster}"
  datacenter           = "${var.datacenter}"
  datastore            = "${var.datastore}"
  host                 = "${var.host}"
  folder               = "${var.folder}"
  convert_to_template  = "true"

  vm_name              = "${var.vm_name}"
  CPUs                 = "${var.vm_cpu_num}"
  RAM                  = "${var.vm_mem_size}"
  RAM_reserve_all      = true
  boot_command = [
    "<esc><esc><esc>",
    "<enter><wait>",
    "/casper/vmlinuz ",
    "initrd=/casper/initrd ",
    "autoinstall ",
    "<enter>"
  ]
  boot_order           = "disk,cdrom"
  boot_wait            = "3s"
  disk_controller_type = ["pvscsi"]

  cd_files = [
    "./cloud-init/meta-data",
    "./cloud-init/user-data"]
  cd_label = "cidata"

  guest_os_type        = "ubuntu64Guest"
  http_directory       = "./http"
  insecure_connection  = "true"
  ip_wait_timeout      = "20m"
  iso_checksum         = "${var.iso_checksum_type}:${var.iso_checksum}"
  iso_urls             = ["${var.iso_url}"]
  network_adapters {
    network      = "${var.network}"
    network_card = "vmxnet3"
  }
  ssh_handshake_attempts = "200"
  ssh_pty                = true
  ssh_timeout            = "20m"
  ssh_username           = "${var.ssh_username}"
  ssh_password           = "${var.ssh_password}"
  storage {
    disk_size             = "${var.vm_disk_size}"
    disk_thin_provisioned = true
  }
}

Operating system and Environment details

Packer runs on CentOS Linux release 8.3.2011
vSphere is 7.0.2

Log Fragments and crash.log files

2021/04/08 12:09:03 packer-builder-vsphere-iso plugin: VM IP aquired: 10.32.0.142
2021/04/08 12:09:04 packer-builder-vsphere-iso plugin: VM IP is still the same: 10.32.0.142
...
2021/04/08 12:12:30 packer-builder-vsphere-iso plugin: [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.32.0.142:22: i/o timeout
2021/04/08 12:12:50 packer-builder-vsphere-iso plugin: [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.32.0.142:22: i/o timeout
2021/04/08 12:12:58 packer-builder-vsphere-iso plugin: [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.32.0.142:22: connect: no route to host
2021/04/08 12:13:06 packer-builder-vsphere-iso plugin: [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.32.0.142:22: connect: no route to host

^--- Here, the ip has changed and is not 10.32.0.142 anymore, so Packed won't reach it ever.

Thank you for you help.

Nicolas

@ghost
Copy link

ghost commented Apr 15, 2021

This issue has been automatically migrated to hashicorp/packer-plugin-vsphere#25 because it looks like an issue with that plugin. If you believe this is not an issue with the plugin, please reply to hashicorp/packer-plugin-vsphere#25.

@ghost
Copy link

ghost commented May 16, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators May 16, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants