hashicorp / packer-plugin-amazon

Packer plugin for Amazon AMI Builder
https://www.packer.io/docs/builders/amazon
Mozilla Public License 2.0
69 stars 104 forks source link

Disk validation failed [Unsupported OVA format] #457

Closed gnoffer closed 4 months ago

gnoffer commented 4 months ago

Overview of the Issue

via packer, i am trying to build a rhel8 vm on vsphere, export to ovf, convert to ova with ovftool from vmware, upload to s3 and create an ami out of it.

Plugin and Packer version

packer-version: 1.10.1 vsphere plugin: 1.2.4 amazon plugin: 1.3.0

Simplified Packer Buildfile

post-processors {
    post-processor "shell-local" {
      inline  = [
        "ovftool -o ${local.ovf_export_path}/${local.vm_name}.ovf ${local.ovf_export_path}/${local.vm_name}.ova"
      ]
    }
    post-processor "artifice" {
      files               = ["${local.ovf_export_path}/${local.vm_name}.ova"]
    }

    post-processor "amazon-import" {
      access_key      = "${var.aws-access-key}" 
      secret_key      = "${var.aws-secret-key}" 
      ami_name        = "${var.ami-name}"
      ami_encrypt     = true
      ami_kms_key     = "arn:aws:kms:eu-central-1:<12345>:key/<xyz>"
      region          = "${var.aws-region}"
      s3_bucket_name  = "ova-deploy-tz"
      license_type    = "BYOL"
      keep_input_artifact = false
      platform        = "linux"
      format          = "ova"
      tags = {
        Description     = "packer amazon import"
        osVersion       = "RHEL8"
        buildDate       = "${local.timestamp}"
        release         = "Latest"
        region          = "{{ .BuildRegion  }}"
        softwareSet     = "Baseimage"
        Base_AMI_Name   = "{{ .SourceAMIName }}"
        Base_AMI_Owner  = "{{ .SourceAMIOwnerName }}"
      }
    }
}

Operating system and Environment details

latest RHEL 8

Log Fragments and crash.log files

==> vsphere-iso.linux-rhel (artifice): Using these artifact files: /home/xxx/packer-examples-for-vsphere/artifacts/kn-template-rhel8.9-aws-2nd/kn-template-rhel8.9-aws-2nd.ova
==> vsphere-iso.linux-rhel: Running post-processor:  (type amazon-import)
    vsphere-iso.linux-rhel (amazon-import): Uploading /home/xxx/packer-examples-for-vsphere/artifacts/kn-template-rhel8.9-aws-2nd/kn-template-rhel8.9-aws-2nd.ova to s3://ova-deploy-tz/packer-import-1707312973.ova
    vsphere-iso.linux-rhel (amazon-import): Completed upload of /home/xxx/packer-examples-for-vsphere/artifacts/kn-template-rhel8.9-aws-2nd/kn-template-rhel8.9-aws-2nd.ova to s3://ova-deploy-tz/packer-import-1707312973.ova
    vsphere-iso.linux-rhel (amazon-import): Setting license type to 'BYOL'
    vsphere-iso.linux-rhel (amazon-import): Started import of s3://ova-deploy-tz/packer-import-1707312973.ova, task id import-ami-060081ae25aa093b7
    vsphere-iso.linux-rhel (amazon-import): Waiting for task import-ami-060081ae25aa093b7 to complete (may take a while)
Build 'vsphere-iso.linux-rhel' errored after 20 minutes 49 seconds: 1 error(s) occurred:

* Post-processor failed: Import task import-ami-060081ae25aa093b7 failed with status message: ClientError: Disk validation failed [Unsupported OVA format], error: ResourceNotReady: failed waiting for successful resource state

==> Wait completed after 20 minutes 49 seconds

==> Some builds didn't complete successfully and had errors:
--> vsphere-iso.linux-rhel: 1 error(s) occurred:
gnoffer commented 4 months ago

here is some logging with debug=1

null.example1 (amazon-import): Setting license type to 'BYOL'
2024/02/07 15:13:48 packer-plugin-amazon_v1.3.0_x5.0_linux_amd64 plugin: 2024/02/07 15:13:48 Calling EC2 to import from s3://ova-deploy-tz/packer-import-1707318800.ova
    null.example1 (amazon-import): Started import of s3://ova-deploy-tz/packer-import-1707318800.ova, task id import-ami-09d54c3a601f5967b
    null.example1 (amazon-import): Waiting for task import-ami-09d54c3a601f5967b to complete (may take a while)
2024/02/07 15:13:54 packer-plugin-amazon_v1.3.0_x5.0_linux_amd64 plugin: 2024/02/07 15:13:54 error: Import task import-ami-09d54c3a601f5967b failed with status message: ClientError: Disk validation failed [Unsupported OVA format], error: ResourceNotReady: failed waiting for successful resource state
2024/02/07 15:13:54 [INFO] (telemetry) ending amazon-import

* Post-processor failed: Import task import-ami-09d54c3a601f5967b failed with status message: ClientError: Disk validation failed [Unsupported OVA format], error: ResourceNotReady: failed waiting for successful resource state
==> Wait completed after 34 seconds 705 milliseconds
2024/02/07 15:13:54 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2024/02/07 15:13:54 machine readable: null.example1,error []string{"1 error(s) occurred:\n\n* Post-processor failed: Import task import-ami-09d54c3a601f5967b failed with status message: ClientError: Disk validation failed [Unsupported OVA format], error: ResourceNotReady: failed waiting for successful resource state"}

* Post-processor failed: Import task import-ami-09d54c3a601f5967b failed with status message: ClientError: Disk validation failed [Unsupported OVA format], error: ResourceNotReady: failed waiting for successful resource state
==> Builds finished but no artifacts were created.
Build 'null.example1' errored after 34 seconds 705 milliseconds: 1 error(s) occurred:

2024/02/07 15:13:54 [INFO] (telemetry) Finalizing.
* Post-processor failed: Import task import-ami-09d54c3a601f5967b failed with status message: ClientError: Disk validation failed [Unsupported OVA format], error: ResourceNotReady: failed waiting for successful resource state

for me it iooks like a corrupt ovf/ova ... ?!

gnoffer commented 4 months ago

anything i do, fails: 1) s3 upload ova generated by packer with rhel8 and lvm, and exported by packer-amazon-plugin to ovf+convert to ova via ovftool or direct export via ofvtool to ova 2) s3 upload a manually installed rhel8 vm without lvm and exported via ovftool directly to ova

both fails to import to aws (by packer-amazon-plugin or also manually via aws-gui).

so there might be some incompatibility between vsphere and aws which isnt documented, yet ?! anyone having same issue or an idea to solve it ?

gnoffer commented 4 months ago

reimport a ova (exported via ovftool) to vcenter(7.0.3) via gui is no problem. so OVA should be OK. switching over to vmdk import is also not possible

gnoffer commented 4 months ago

i have it: kms key had no permission in my IAM Policy for vmimport.