packer-builder-vsphere icon indicating copy to clipboard operation
packer-builder-vsphere copied to clipboard

502 Proxy Error while waiting for IP

Open spstratis opened this issue 6 years ago • 2 comments

I'm in a vSphere/vCenter 6.5 private cloud environment. The vsphere-iso packer script is getting to the Waiting for IP phase while building my Ubuntu 18.04 image but after a few minutes failing with the following error.

Build 'vsphere-iso' errored: 502 Proxy Error

Any idea what could be the cause of this? I'm unfortunately not seeing any additional logging information that could give me a place to look.

Below is a print out of the logs. https://gist.github.com/spstratis/b286519455d79a68c2ae7d863a83bfa9

And here is my packer script with sensitive values hidden.

{
  "builders": [
    {
      "type": "vsphere-iso",

      "vcenter_server": "{{user `vsphere_domain`}}",
      "username": "{{user `vsphere_user`}}",
      "password": "{{user `vsphere_pass`}}",
      "insecure_connection": "false",

      "vm_name": "newyu_ubuntu1804",
      "cluster":"Cluster1",
      "host":"{{user `vsphere_host`}}",
      "guest_os_type": "ubuntu64Guest",

      "datastore": "pcc-005044",
      "network": "VM Network",      
      "convert_to_template": "true",
      "folder":"Newyu",

      "ssh_username": "dev",
      "ssh_password": "dev",

      "CPUs": 1,
      "RAM": 1024,
      "RAM_reserve_all": true,
      
      "disk_size": 32768,
      "disk_thin_provisioned": false,

      "network_card": "vmxnet3",
      
      "iso_checksum": "{{user `iso_checksum`}}",
      "iso_checksum_type": "{{user `iso_checksum_type`}}",
      "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
      "http_directory": "http",
      "boot_command": [
        "<esc><wait>",
        "<esc><wait>",
        "<enter><wait>",
        "/install/vmlinuz<wait>",
        " auto<wait>",
        " console-setup/ask_detect=false<wait>",
        " console-setup/layoutcode=us<wait>",
        " console-setup/modelcode=pc105<wait>",
        " debconf/frontend=noninteractive<wait>",
        " debian-installer=en_US.UTF-8<wait>",
        " fb=false<wait>",
        " initrd=/install/initrd.gz<wait>",
        " kbd-chooser/method=us<wait>",
        " keyboard-configuration/layout=USA<wait>",
        " keyboard-configuration/variant=USA<wait>",
        " locale=en_US.UTF-8<wait>",
        " netcfg/get_domain=vm<wait>",
        " netcfg/get_hostname=ubuntubase<wait>",
        " grub-installer/bootdev=/dev/sda<wait>",
        " noapic<wait>",
        " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}}<wait>",
        " -- <wait>",
        "<enter><wait>"
      ]
    }
  ],
  "variables": {
    "cpus": "1",
    "disk_size": "65536",
    "headless": "true",
    "iso_checksum": "a5b0ea5918f850124f3d72ef4b85bda82f0fcd02ec721be19c1a6952791c8ee8",
    "iso_checksum_type": "sha256",
    "iso_name": "ubuntu-18.04.1-server-amd64.iso",
    "memory": "1024",
    "mirror": "http://cdimage.ubuntu.com",
    "mirror_directory": "ubuntu/releases/18.04.1/release",
    "name": "ubuntu-18.04",
    "preseed_path": "preseed.cfg",
    "template": "ubuntu-18.04-amd64",

    "vsphere_ip": "x.x.x.x",
    "vsphere_host": "x.x.x.x",
    "vsphere_domain": "pcc-x-x-x-x.ovh.com",
    "vsphere_user": "admin",
    "vsphere_pass": "<password>",
    "vsphere_datacenter": "datacenter-41",
    "vsphere_cluster": "domain-c46",
    "vsphere_datastore": "pcc-005044",
    "vsphere_network": "VM Network"
  }
}

spstratis avatar Feb 01 '19 17:02 spstratis

same issue.

this is my packer file :

{
    "variables": {
      "vcenter_host": "xxxxx",
      "vcenter_user": "xxxxx",
      "vcenter_password": "xxxxx",
      "ssh_user": "xxxxx",
      "ssh_password": "xxxxx",
      "dc": "xxxxx",
      "cluster": "xxxxx",
      "network": "xxxxx",
      "storage": "xxxxx",
      "ks_file": "ks.cfg",
      "cpu_cores": "1",
      "ram_mb": "1024",
      "disk_size_mb": "20480"
    },
  
    "builders": [
      {
        "type": "vsphere-iso",
  
        "vcenter_server":      "{{ user `vcenter_host` }}",
        "username":            "{{ user `vcenter_user` }}",
        "password":            "{{ user `vcenter_password` }}",
        "insecure_connection": "true",
        "ssh_username": "{{ user `ssh_user` }}",
        "ssh_password": "{{ user `ssh_password` }}",
  
        "datacenter": "{{ user `dc` }}",
        "cluster": "{{ user `cluster` }}",
        "network": "{{ user `network` }}",
        "network_card": "vmxnet3",
        "datastore": "{{ user `storage` }}",
        "vm_name": "centos7_test",
        "guest_os_type": "rhel7_64Guest",
  
        "CPUs":             "{{ user `cpu_cores` }}",
        "RAM":              "{{ user `ram_mb` }}",
        "RAM_reserve_all": true,
        "convert_to_template": false,
  
        "disk_controller_type":  "pvscsi",
        "disk_size":        "{{ user `disk_size_mb` }}",
        "disk_thin_provisioned": true,

  
        "iso_paths": [
            "[pcc-008353] upload/CentOS-7-x86_64-Minimal-1810.iso"
        ],

        "floppy_files": [
          "{{template_dir}}/ks.cfg"
        ],
        "boot_wait": "10s",
        "boot_command": [
          "<esc>",
          "<wait>linux inst.ks=hd:/dev/fd0:/ks.cfg<enter>"
        ]
       }
    ],
  
    "provisioners": [
      {
        "type": "shell",
        "inline": [ "ls /"],
        "execute_command": "echo 'root' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
        "pause_before": "10s"
      }
    ]
  }

and my %post installation ks.cfg

%post --log=/tmp/ks-post.log
/usr/bin/yum install -y epel-release
/usr/bin/yum install -y open-vm-tools
/usr/bin/systemctl enable vmtoolsd
/usr/bin/systemctl start vmtoolsd
/usr/bin/yum install -y bzip2
/usr/bin/yum install -y kernel-devel
/usr/bin/yum install -y kernel-headers
/usr/bin/yum update -y
%end

Output from packer build

==> vsphere-iso: Creating VM...
==> vsphere-iso: Customizing hardware...
==> vsphere-iso: Mount ISO images...
==> vsphere-iso: Creating floppy disk...
    vsphere-iso: Copying files flatly from floppy_files
    vsphere-iso: Copying file: /Users/xxxx/Documents/xxx/ks.cfg
    vsphere-iso: Done copying files from floppy_files
    vsphere-iso: Collecting paths from floppy_dirs
    vsphere-iso: Resulting paths from floppy_dirs : []
    vsphere-iso: Done copying paths from floppy_dirs
==> vsphere-iso: Uploading created floppy image
==> vsphere-iso: Adding generated Floppy...
==> vsphere-iso: Set boot order temporary...
==> vsphere-iso: Power on VM...
==> vsphere-iso: Waiting 10s for boot...
==> vsphere-iso: Typing boot command...
==> vsphere-iso: Waiting for IP...
==> vsphere-iso: Clear boot order...
==> vsphere-iso: Power off VM...
==> vsphere-iso: Deleting Floppy image ...
==> vsphere-iso: Destroying VM...
Build 'vsphere-iso' errored: 502 Proxy Error

==> Some builds didn't complete successfully and had errors:
--> vsphere-iso: 502 Proxy Error

==> Builds finished but no artifacts were created.

Thanks for your help

MacFlurry avatar Jun 17 '19 13:06 MacFlurry

My first time out this evening with this plugin, packer 1.3.3 and vCenter 6.7 yielded some interesting results:

  • Started with Ubuntu 16.04; got to the point where the VM came up and was provisioned using preseed successfully, but packer never got past the "Waiting for IP" stage

  • Moved on to Ubuntu 18.04. Used the standard (live) image, and the VM came up, but of course the preseed fails, but packer got past the "Waiting for IP" stage and then got stuck at the "Waiting for SSH to become available" stage

  • I assumed that this was because of Subiquity and the preseed recipe failing, so I moved to the legacy, non-live 18.04 image. When I ran that, preseed worked flawlessly, but packer was still stuck at "Waiting for IP".

My configuration:

{
  "builders": [
    {
      "type": "vsphere-iso",

      "vcenter_server":      "vcenter.example.com",
      "username":            "[email protected]",
      "password":            "S3kr1t",
      "insecure_connection": "true",

      "vm_name": "example-ubuntu",
      "cluster": "CLUSTER-01",
      "host": "esxi2.example.com",
      "datastore": "VMSTORE-03",

      "guest_os_type": "ubuntu64Guest",

      "ssh_username": "vagrant",
      "ssh_password": "vagrant",

      "CPUs":             1,
      "RAM":              2048,
      "RAM_reserve_all": true,

      "disk_controller_type":  "scsi",
      "disk_size":        "32768",
      "disk_thin_provisioned": true,

      "network": "VLAN100",
      "network_card": "vmxnet3",
      "usb_controller": true,

      "cdrom_type": "ide",

      "iso_paths": [
        "[VMSTORE-03] ISO/ubuntu-18.04.2-server-amd64.iso"
      ],

      "floppy_files": [
        "{{template_dir}}/preseed.cfg"
      ],

      "boot_command": [
        "<enter><wait><f6><wait><esc><wait>",
        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
        "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
        "<bs><bs><bs>",
        "/install/vmlinuz noapic ",
        "debconf/frontend=noninteractive ",
        "debian-installer=en_US auto ",
        "fb=false ",
        "hostname=example-ubuntu ",
        "initrd=/install/initrd.gz ",
        "kbd-chooser/method=us ",
        "keyboard-configuration/layoutcode=us ",
        "keyboard-configuration/layout=USA ",
        "keyboard-configuration/variant=USA ",
        "locale=en_US ",
        "passwd/user-fullname=Vagrant ",
        "passwd/user-password=vagrant ",
        "passwd/user-password-again=vagrant ",
        "passwd/username=vagrant ",
        "file=/media/preseed.cfg ",
        "initrd=/install/initrd.gz ",
        "-- ",
        "<enter>"
      ]
    }
  ],

  "provisioners": [
    {
      "type": "shell",
      "inline": ["ls /"]
    }
  ]
}

I'm a bit baffled by why with the same environment, one distro gets past the IP status, and the rest do not.

Thanks for any clues you might be able to provide.

techn0mad avatar Jul 03 '19 06:07 techn0mad