josenk / terraform-provider-esxi

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

Terraform plan fails with exit status 127 - Error: There was an ovftool Error: #123

Closed sadaramk closed 4 years ago

sadaramk commented 4 years ago

Describe the bug I am getting an error when I try on a mac.

To Reproduce Steps to reproduce the behavior:

  1. Terraform apply
  2. See error below

2020/09/01 21:28:04 [DEBUG] esxi_guest.vmtest: apply errored, but we're indicating that via the Error pointer rather than returning it: There was an ovftool Error: exit status 127 2020/09/01 21:28:04 [ERROR] eval: terraform.EvalApplyPost, err: There was an ovftool Error: exit status 127 2020/09/01 21:28:04 [ERROR] eval: terraform.EvalSequence, err: There was an ovftool Error: exit status 127

I went through below post and added path to ~/.bash_profile and can also run ovftool however I still get the error https://github.com/josenk/terraform-provider-esxi/issues/50

path set in ~/.bash_profile

Setting PATH for OVFTool

PATH="/Applications/VMware\ OVF\ Tool/ovftool:${PATH}" export PATH

Error: There was an ovftool Error: exit status 127

Suspect it has to do with path not found for osShellCmd = "/bin/bash" in guest-create.go line 281 onwards. Tried all options to set path but none of the options worked.

Expected behavior Expect to execute ovftool.

Terraform files Below is my main.tf terraform { required_version = ">= 0.13" required_providers { esxi = { source = "registry.terraform.io/josenk/esxi" #

For more information, see the provider source documentation:

  # https://github.com/josenk/terraform-provider-esxi
  # https://registry.terraform.io/providers/josenk/esxi
}

} }

provider "esxi" { esxi_hostname = "192.168.0.195" esxi_hostport = "22" esxi_hostssl = "443" esxi_username = "root" esxi_password = "PWD }

resource "esxi_guest" "vmtest" { guest_name = "vmtest" disk_store = "datastore1" ovf_source = "https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64.ova"

#

Specify an existing guest to clone, an ovf source, or neither to build a bare-metal guest vm.

#

clone_from_vm = "Templates/centos7"

ovf_source = "/local_path/centos-7.vmx"

network_interfaces { virtual_network = "VM Network" } }

Desktop (please complete the following information):

Additional context Terraform log is below 2020/09/01 21:41:04 [INFO] backend/local: apply calling Apply 2020/09/01 21:41:04 [INFO] terraform: building graph: GraphTypeApply 2020/09/01 21:41:04 [DEBUG] Resource state not found for node "esxi_guest.vmtest", instance esxi_guest.vmtest 2020/09/01 21:41:04 [DEBUG] ProviderTransformer: "esxi_guest.vmtest (expand)" (terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/josenk/esxi"] 2020/09/01 21:41:04 [DEBUG] ProviderTransformer: "esxi_guest.vmtest" (terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/josenk/esxi"] 2020/09/01 21:41:04 [DEBUG] ReferenceTransformer: "esxi_guest.vmtest (expand)" references: [] 2020/09/01 21:41:04 [DEBUG] ReferenceTransformer: "esxi_guest.vmtest" references: [] 2020/09/01 21:41:04 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/josenk/esxi\"]" references: [] 2020/09/01 21:41:04 [DEBUG] Starting graph walk: walkApply 2020-09-01T21:41:04.802+1000 [INFO] plugin: configuring client automatic mTLS 2020-09-01T21:41:04.845+1000 [DEBUG] plugin: starting plugin: path=.terraform/plugins/registry.terraform.io/josenk/esxi/1.7.1/darwin_amd64/terraform-provider-esxi_v1.7.1 args=[.terraform/plugins/registry.terraform.io/josenk/esxi/1.7.1/darwin_amd64/terraform-provider-esxi_v1.7.1] 2020-09-01T21:41:04.850+1000 [DEBUG] plugin: plugin started: path=.terraform/plugins/registry.terraform.io/josenk/esxi/1.7.1/darwin_amd64/terraform-provider-esxi_v1.7.1 pid=54137 2020-09-01T21:41:04.850+1000 [DEBUG] plugin: waiting for RPC address: path=.terraform/plugins/registry.terraform.io/josenk/esxi/1.7.1/darwin_amd64/terraform-provider-esxi_v1.7.1 2020-09-01T21:41:04.865+1000 [INFO] plugin.terraform-provider-esxi_v1.7.1: configuring server automatic mTLS: timestamp=2020-09-01T21:41:04.865+1000 2020-09-01T21:41:04.902+1000 [DEBUG] plugin.terraform-provider-esxi_v1.7.1: plugin address: address=/var/folders/84/bzjrmxj121n8nb7rj97wg2gh0000gn/T/plugin790507076 network=unix timestamp=2020-09-01T21:41:04.902+1000 2020-09-01T21:41:04.902+1000 [DEBUG] plugin: using plugin: version=5 2020-09-01T21:41:04.979+1000 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unimplemented desc = unknown service plugin.GRPCStdio" 2020-09-01T21:41:04.980+1000 [DEBUG] plugin.terraform-provider-esxi_v1.7.1: pid-54137-config.go:18: [validateEsxiCreds] 2020-09-01T21:41:04.980+1000 [DEBUG] plugin.terraform-provider-esxi_v1.7.1: pid-54137-esxi_remote_cmds.go:61: [runRemoteSshCommand] :Connectivity test, get vmware version 2020-09-01T21:41:05.088+1000 [DEBUG] plugin.terraform-provider-esxi_v1.7.1: pid-54137-esxi_remote_cmds.go:78: [runRemoteSshCommand] cmd:/vmware --version/ 2020-09-01T21:41:05.088+1000 [DEBUG] plugin.terraform-provider-esxi_v1.7.1: stdout:/VMware ESXi 7.0.0 build-16324942/ 2020-09-01T21:41:05.088+1000 [DEBUG] plugin.terraform-provider-esxi_v1.7.1: stderr:/%!s()/ 2020/09/01 21:41:05 [WARN] Provider "registry.terraform.io/josenk/esxi" produced an invalid plan for esxi_guest.vmtest, but we are tolerating it because it is using the legacy plugin SDK. The following problems may be the cause of any confusing errors from downstream operations:

Error: There was an ovftool Error: exit status 127

on main.tf line 22, in resource "esxi_guest" "vmtest": 22: resource "esxi_guest" "vmtest" {

josenk commented 4 years ago

On the command line (where your main.tf is located), does this command work? ovftool --acceptAllEulas --noSSLVerify --X:useMacNaming=false -dm=thin --name='vmtest' --overwrite -ds='datastore1' --network='VM Network' 'https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64.ova' 'vi://XXXX:YYYY@192.168.0.195:443/'

If it cannot find ovftool, then you did not set your path correctly.

sadaramk commented 4 years ago

On the command line (where your main.tf is located), does this command work?

ovftool --acceptAllEulas --noSSLVerify --X:useMacNaming=false -dm=thin --name='vmtest' --overwrite -ds='datastore1' --network='VM Network' 'https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64.ova' 'vi://XXXX:YYYY@192.168.0.195:443/'

If it cannot find ovftool, then you did not set your path correctly.

Yes command works from terminal, I believe add-on is trying to run /bin/bash ovftool which is resulting in this error.

josenk commented 4 years ago

If bash is missing, have you tried installing it.

sadaramk commented 4 years ago

Bash is working and I tested with other commands.

josenk commented 4 years ago

Sorry, I don't have a mac to try to reproduce your problem. The only clue to what's your problem is the "Error 127" typically meaning command not found.. I suspect there's a problem with your environment. Can you try another system?

sadaramk commented 4 years ago

Thank you Josenk, i tested the same code in linux and it worked fine. I guess this could environment or mac only issue. Appreciate your prompt response

Rahulsharma0810 commented 3 years ago

I am also getting this issue, on mac.

ghokun commented 3 years ago

I was getting the same error and solved like this: