josenk / terraform-provider-esxi

Terraform-provider-esxi plugin
GNU General Public License v3.0
540 stars 154 forks source link

[help] Not able to configure ubuntu cloud image #140

Closed bilak closed 3 years ago

bilak commented 3 years ago

Hello, I'm trying to install ubuntu cloud image 20.04 to esxi 7.0 with following files:

main.tf

provider "esxi" {
  esxi_hostname = var.esxi_hostname
  esxi_hostport = var.esxi_hostport
  esxi_username = var.esxi_username
  esxi_password = var.esxi_password
}

resource "esxi_guest" "default" {
  guest_name    = var.guest_name
  disk_store    = var.disk_store
  ovf_source    = "/tmp/focal-server-cloudimg-amd64.ova"
  network_interfaces {
    virtual_network = "VM Network"
  }

  guestinfo = {
    "metadata" = base64gzip(file("metadata.yml"))
    "metadata.encoding" = "gzip+base64"
    "userdata" = base64gzip(file("userdata.yml"))
    "userdata.encodinng" = "gzip+base64"
  }
}

metadata.yml

#cloud-config
network:
  version: 2
  ethernets:
    ens160:
      dhcp4: true
      dhcp6: false
      gateway4: 192.168.240.1
      nameservers:
        addresses:
          - 192.168.240.1

userdata.yml

#cloud-config
users:
  - name: test
    lock-passwd: false
    groups: sudo
    plain_text_passwd: test

locale: en_US.UTF-8
timezone: Europe/Prague
hostname: testserver
package_upgrade: true

however when I start the machine I'm not able to login with test/test and there is also no network being configured. Before entering login prompt I can see error like on image bellow I think that's related to floppy. I don't know if that can cause some issue or not.

image

can you please advice what do I have to check? ovftool + vmware-guestinfo is installed, I'm using it from docker image

FROM ubuntu:20.04
ADD VMware-ovftool-4.4.0-15722219-lin.x86_64.bundle /tmp/ovftool.bundle
RUN apt update && apt install -y \
    cloud-init \
    gnupg \
    software-properties-common \
    curl && \
    cd /tmp && \
    curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - && \
    apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
    apt update && apt install terraform && \
    curl -sSL https://raw.githubusercontent.com/vmware/cloud-init-vmware-guestinfo/master/install.sh | sh - && \
    /tmp/ovftool.bundle --eulas-agreed && \
    rm -f /tmp/ovftool.bundle && \
    apt autoremove -y && \
    apt clean
josenk commented 3 years ago

Sorry, I don't support the cloud images. Looks like the provider is working as expected. I don't believe that floppy error message has anything to do with your problem.

I suggest you start with something simple and get it working... Then work your way up to this.

bilak commented 3 years ago

Hello, seems that there is some issue like described here read from comment #25. Seems like there is a clash between vmware tools and cloud-init. I will try to look into it more today just found it yesterday at lat night.

And you are right, floppy has nothing to do with this.

edit: I think this could help to solve the issue, I just need to find out the way how to do that. As far as I understand it's not possible to get into OVA that easily while it doesn't have created any user.

vmware-toolbox-cmd config set deployPkg enable-custom-scripts false
vmware-toolbox-cmd config set deployPkg enable-customization false
thony-p commented 3 years ago

Hi @bilak, I have the same issue on my homelab. Did you find the solution?

josenk commented 3 years ago

Closing this issue... This is not provider related.