ESXi and vnc

1,033 views
Skip to first unread message

Mauricio Tavares

unread,
Jun 8, 2014, 6:59:21 PM6/8/14
to packe...@googlegroups.com
(Ok, this time it is posted to the right list!)

So I am learning about the way of the packer and this is my first test template:

{
  "builders": [
    {
      "type": "vmware-iso",
      "guest_os_type" : "ubuntu64",
      "iso_url": "http://old-releases.ubuntu.com/releases/precise/ubuntu-12.04.2-server-amd64.iso",
      "iso_checksum": "af5f788aee1b32c4b2634734309cc9e9",
      "iso_checksum_type": "md5",
      "disk_size": "10240",
      "disk_type_id": "thin",
      "vmdk_name": "test",
      "vmx_data" : {
        "cpuid.coresPerSocket": "1",
        "numvcpus": "1",
        "ethernet0.networkName": "LAN",
        "memsize": "1024"
      },
      "ssh_username" : "bubba",
      "ssh_password" : "test123",
      "ssh_wait_timeout": "30s",
      "remote_type": "esx5",
      "remote_host": "exsi.domain.com",
      "remote_datastore": "datastore1",
      "remote_username": "admin",
      "remote_password": "password",
      "boot_command": [
        "<esc><esc><enter><wait>",
          "/install/vmlinuz noapic ",
          "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
          "hostname={{ .Name }} ",
          "fb=false debconf/frontend=noninteractive ",
          "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
          "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
          "initrd=/install/initrd.gz -- <enter>"
      ],
      "boot_wait": "20s",
      "shutdown_command": "shutdown -P now"
    }
  ]
}

When I go build it, I get this message about not being able to connect to it using vnc:

raub@desktop:~/dev/packer$ packer build test.json
vmware-iso output will be in this color.

==> vmware-iso: Downloading or copying ISO
    vmware-iso: Downloading or copying: http://old-releases.ubuntu.com/releases/precise/ubuntu-12.04.2-server-amd64.iso
==> vmware-iso: Uploading ISO to remote machine...
==> vmware-iso: Creating virtual machine disk
==> vmware-iso: Building and writing VMX file
==> vmware-iso: Registering remote VM...
==> vmware-iso: Starting virtual machine...
==> vmware-iso: Waiting 20s for boot...
==> vmware-iso: Connecting to VM via VNC
==> vmware-iso: Error connecting to VNC: dial tcp 10.0.0.20:5988: connection refused
==> vmware-iso: Unregistering virtual machine...
==> vmware-iso: Deleting output directory...
Build 'vmware-iso' errored: Error connecting to VNC: dial tcp 10.0.0.20:5988: connection refused

==> Some builds didn't complete successfully and had errors:
--> vmware-iso: Error connecting to VNC: dial tcp 10.0.0.20:5988: connection refused

==> Builds finished but no artifacts were created.
raub@desktop:~/dev/packer$

Is this an issue with my config or something I did not do in the esxi box?

日下部雄也

unread,
Jun 8, 2014, 7:27:16 PM6/8/14
to packe...@googlegroups.com
Hi,

I guess you need to open firewall in ESXi for vnc with vSphere Client or /etc/vmware/firewall/service.xml.
And use 'vnc_port_min' and 'vnc_port_max' to fix the port.

Reference:



--
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
日下部 雄也 (KUSAKABE Yuya)

Mauricio Tavares

unread,
Jul 2, 2014, 2:03:14 PM7/2/14
to packe...@googlegroups.com


On Sunday, June 8, 2014 7:27:16 PM UTC-4, 日下部雄也 wrote:
Hi,

I guess you need to open firewall in ESXi for vnc with vSphere Client or /etc/vmware/firewall/service.xml.
And use 'vnc_port_min' and 'vnc_port_max' to fix the port.

Reference:


     Thanks for the suggestions. So, I opened the port 5900 in the ESXi firewall; I did test that using netcat as the service. Then I edited the test.json file and set
   
      "vnc_port_min": 5900,
      "vnc_port_max": 5900,

and run the build again. Only change is it is reporting connection refused on port 5900:

==> vmware-iso: Error connecting to VNC: dial tcp 10.0.0.20:5900: connection refused
 

Yathindra Raj

unread,
Feb 14, 2015, 10:45:29 AM2/14/15
to packe...@googlegroups.com
Hey Mauricio Tavares ,
                                       Edit "vnc_port_min" and "vnc_port_max in json file similar to what you have specified in /etc/vmware/firewall/service.xml.
Most importantly check whether have you specified "inbound" and "outbound" rules in service.xml for "vncServer" you configured.
Still if thinks don't work then chmod  644 /etc/vmware/firewall/service.xml.
try using vnc_port_min :5800 and vnc_port_max:5999.


Thanks,
Yathindra 


Yathindra Raj

unread,
Feb 14, 2015, 10:46:55 AM2/14/15
to packe...@googlegroups.com
hey,
    This worked for me.If any better way please drop your suggestion.

Mauricio Tavares

unread,
Feb 23, 2015, 4:58:54 PM2/23/15
to packe...@googlegroups.com


On Saturday, February 14, 2015 at 10:46:55 AM UTC-5, Yathindra Raj wrote:
hey,
    This worked for me.If any better way please drop your suggestion.


      I know I am doing something wrong but still do not know what. Per you suggestion, I have in /etc/vmware/firewall/service.xml (service id 0033 because there are 32 services before it):

  <!-- VNC -->
  <service id="0033">
    <id>VNC</id>
    <rule id='0000'>
        <direction>outbound</direction>
        <protocol>tcp</protocol>
        <porttype>dst</porttype>
        <port>
           <begin>5800</begin>
           <end>5999</end>
        </port>
     </rule>
    <rule id='0001'>
        <direction>inbound</direction>
        <protocol>tcp</protocol>
        <porttype>dst</porttype>
        <port>
           <begin>5800</begin>
           <end>5999</end>
        </port>
     </rule>
     <enabled>true</enabled>
     <required>false</required>
  </service>


Added
      "vnc_port_min": 5800,
      "vnc_port_max": 5999,

to my test.json file and then ran it:


raub@desktop:~/dev/packer$ packer build test.json
vmware-iso output will be in this color.

==> vmware-iso: Downloading or copying ISO
    vmware-iso: Downloading or copying: http://old-releases.ubuntu.com/releases/precise/ubuntu-12.04.2-server-amd64.iso
==> vmware-iso: Uploading ISO to remote machine...
==> vmware-iso: Creating virtual machine disk
==> vmware-iso: Building and writing VMX file
==> vmware-iso: Registering remote VM...
==> vmware-iso: Starting virtual machine...
==> vmware-iso: Waiting 20s for boot...
==> vmware-iso: Connecting to VM via VNC
==> vmware-iso: Error connecting to VNC: dial tcp 10.0.0.20:5800: connection refused

==> vmware-iso: Unregistering virtual machine...
==> vmware-iso: Deleting output directory...
Build 'vmware-iso' errored: Error connecting to VNC: dial tcp 10.0.0.20:5800: connection refused


==> Some builds didn't complete successfully and had errors:
--> vmware-iso: Error connecting to VNC: dial tcp 10.0.0.20:5800: connection refused


==> Builds finished but no artifacts were created.
raub@desktop:~/dev/packer$


I did test connectivity to that port using netcat and was successful, which makes me think it isn't a firewall issue.
 

Mauricio Tavares

unread,
Feb 24, 2015, 7:49:16 AM2/24/15
to packe...@googlegroups.com

      A bit of an update, https://groups.google.com/forum/#!topic/packer-tool/qjGb34DnFc4 showed me what I was doing wrong: I should have had

      "guest_os_type" : "ubuntu-64",

Instead of

      "guest_os_type" : "ubuntu64",

as I previously had (see original post). Now, we have progressed to a different issue:


raub@desktop:~/dev/packer$ packer build test.json
vmware-iso output will be in this color.

==> vmware-iso: Downloading or copying ISO
    vmware-iso: Downloading or copying: http://old-releases.ubuntu.com/releases/precise/ubuntu-12.04.2-server-amd64.iso
==> vmware-iso: Uploading ISO to remote machine...
==> vmware-iso: Creating virtual machine disk
==> vmware-iso: Building and writing VMX file
==> vmware-iso: Registering remote VM...
==> vmware-iso: Starting virtual machine...
==> vmware-iso: Waiting 20s for boot...
==> vmware-iso: Connecting to VM via VNC
==> vmware-iso: Typing the boot command over VNC...
==> vmware-iso: Waiting for SSH to become available...
==> vmware-iso: Timeout waiting for SSH.
==> vmware-iso: Stopping virtual machine...

==> vmware-iso: Unregistering virtual machine...
==> vmware-iso: Deleting output directory...
Build 'vmware-iso' errored: Timeout waiting for SSH.


==> Some builds didn't complete successfully and had errors:
--> vmware-iso: Timeout waiting for SSH.


==> Builds finished but no artifacts were created.
raub@desktop:~/dev/packer$

Progress has been made!

Ethan S.

unread,
Feb 24, 2015, 12:48:19 PM2/24/15
to packe...@googlegroups.com
Your SSH timeout wait is WAY too short. You should increase it to 20 minutes or more. If you are use a preseed to install Ubuntu and then connecting to the finished machine to provision, you have to remember depending on the network link speed it can take a long time to get the packages. Also, unless you enable SSH during the preseed phase, Packer can never connect until the OS is done and booted, and even then you need something enabled to install openssh for Packer to connect to.

Mauricio Tavares

unread,
Mar 4, 2015, 1:56:38 PM3/4/15
to packe...@googlegroups.com


On Tuesday, February 24, 2015 at 12:48:19 PM UTC-5, Ethan S. wrote:
Your SSH timeout wait is WAY too short. You should increase it to 20 minutes or more. If you are use a preseed to install Ubuntu and then connecting to the finished machine to provision, you have to remember depending on the network link speed it can take a long time to get the packages. Also, unless you enable SSH during the preseed phase, Packer can never connect until the OS is done and booted, and even then you need something enabled to install openssh for Packer to connect to.

      Thanks, I changed that and decided to be slightly clever and have console on the vm as packer was doing its thing. It turned out it was hanging on the partitioning step, waiting for me to  let it commit the new partition. Since I am doing a LVM, I told it to


d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

after partitioning. That seemed to have done the trick though I wonder if it a bit of overkill.
Reply all
Reply to author
Forward
0 new messages