Error using provisioner file and remote exec, with file not being found after upload.

508 views
Skip to first unread message

SurferL

unread,
Jan 24, 2018, 11:44:37 AM1/24/18
to Terraform
Version: Terraform v0.11.1

I'm having an issue where, I'm using the terraform-provider-vsphere, to stand up a VM in vsphere, and upload a python script, and then run the python script. However, on some occasions (seems random), after the file upload, it fails the following `provisioner "remote-exec"` stage as it can't find the file. Around 80% it works fine, so I'm a bit stumped...

```
* stat /.../terraform/test_env/.terraform/modules/f841ba80c506702640750cd77038b2e4/scripts/deploy.py: no such file or directory
* module.inf-win7.vsphere_virtual_machine.vpshere_build_machine: 1 error(s) occurred:
```

It seems that the file it is trying to locate is on the local machine and not on the remote one?

Any ideas how I can fix this? (I used the examples online here: https://www.terraform.io/docs/provisioners/remote-exec.html#script-arguments).

Thanks!


# Create virtual machine and provision deployment
resource "vsphere_virtual_machine" "vpshere_build_machine" {
name = "${var.vm_name}"
folder = "${var.vm_folder}"
        ...

# Upload deploy script
provisioner "file" {
connection {
type = "${var.connection_type}"
insecure = true
user = "${var.user}"
password = "${var.password}"
}

source = "${path.module}/scripts/deploy.py"
destination = "${var.working_dir}/deploy.py"
}

# Run deploy script on remote machine
provisioner "remote-exec" {
connection {
type = "${var.connection_type}"
insecure = true
user = "${var.user}"
password = "${var.password}"
}

inline = [
"python ${var.working_dir}/deploy.py"
]
}
}





Reply all
Reply to author
Forward
0 new messages