josenk / terraform-provider-esxi

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

Ovftool error while using ovf_source ( Terraform) #205

Closed oussexist closed 1 year ago

oussexist commented 1 year ago

Hello everyone , Just a beginner here , so i want to deploy some virtual machines using terraform with josenk esxi provider , it works everything fine , just the operating system problem , at first i was using cdrom prop but noticed it's not working , so i tried to use "ovf_source" since i uploaded an ova file of an ubuntu template or even i tried to use the ubuntu image given in the description of the git. but it's not working , i am getting an ovftool error. Here is the error : Enter a value: yes

module.instance.esxi_guest.VM[1]: Creating... module.instance.esxi_guest.VM[0]: Creating... ╷ │ Error: There was an ovftool Error: │ C:\Users\majho\Desktop\terraformf>ovftool --acceptAllEulas --noSSLVerify --X:useMacNaming=false -dm=thin --name="vm-terraformed+0" --overwrite -ds="datastore1" --network="VM Network-terraformed" "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.ova" "vi://root:oUSSE%3BQ%218@192.168.120.134:443//" │ │ exit status 1 │ │ │ with module.instance.esxi_guest.VM[0], │ on vm_module\main.tf line 19, in resource "esxi_guest" "VM": │ 19: resource "esxi_guest" "VM" { │ ╵ ╷ │ Error: There was an ovftool Error: │ C:\Users\majho\Desktop\terraformf>ovftool --acceptAllEulas --noSSLVerify --X:useMacNaming=false -dm=thin --name="vm-terraformed+1" --overwrite -ds="datastore1" --network="VM Network-terraformed" "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.ova" "vi://root:oUSSE%3BQ%218@192.168.120.134:443//" │ │ exit status 1 │ │ │ with module.instance.esxi_guest.VM[1], │ on vm_module\main.tf line 19, in resource "esxi_guest" "VM": │

Code : terraform { required_version = ">= 1.2.5" required_providers { esxi = { source = "registry.terraform.io/josenk/esxi" } } }

resource "esxi_vswitch" "myvswitch" { name = "My vSwitch" }

resource "esxi_portgroup" "myportgroup" { name = "VM Network-terraformed" vswitch = esxi_vswitch.myvswitch.name } resource "esxi_guest" "VM" { count = 2 guest_name = "${var.guest_name}+${count.index}" numvcpus = var.cpu_count memsize = var.memory_size disk_store = var.esxi_datastore boot_disk_size = var.disk_size ovf_source = "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.ova" network_interfaces { virtual_network = esxi_portgroup.myportgroup.name }

} so this is in the main of a module and then i called an instance of the module in another file its all fine with variables files and the structure of the files etc. Please Note that am a beginner in this domain , so if this issue already answered somewhere and i didnt exactly get it then just thanks to give the solution again and thanks. P.S : I really dont know if the ovftool already installed on my esxi host or not, just installed and configured an esxi on a vmware workstation vm , so normally it should be installed already on the esxi as i saw in some comments here : https://www.reddit.com/r/vmware/comments/xxm7bp/how_to_install_vmware_ovftool_in_esxi_7/.

josenk commented 1 year ago

Do you have any additional details for this problem?

This provider doesn't support installing ovftool on the esxi host. (Neither does vmware)

oussexist commented 1 year ago

i mean the error is caused by the arg ovf_source , for the os image , if it dosent support it then how to implement an os to the vm ? because when i make the ovf_source arg in comment or remove it , it terraform applies fine. Thanks for your response.