Open franfran3 opened 5 years ago
Hmm, looks like an issue with the provisioner / connection behaviour? @paddycarver do you mind looking in to this when you have cycles?
Hey @franfran3, sorry for the delayed response on this. Are you still seeing this issue on 0.12?
Can confirm the same behaviour with newest TF version.
Terraform v0.12.18
+ provider.google v2.14.0
+ provider.local v1.3.0
+ provider.template v2.1.2
google_compute_instance.gitlab-ci-runner: Destroying... [id=runner]
google_compute_instance.gitlab-ci-runner: Provisioning with 'remote-exec'...
google_compute_instance.gitlab-ci-runner (remote-exec): Connecting to remote host via SSH...
google_compute_instance.gitlab-ci-runner (remote-exec): Host:
google_compute_instance.gitlab-ci-runner (remote-exec): User: root
google_compute_instance.gitlab-ci-runner (remote-exec): Password: false
google_compute_instance.gitlab-ci-runner (remote-exec): Private key: false
google_compute_instance.gitlab-ci-runner (remote-exec): Certificate: false
google_compute_instance.gitlab-ci-runner (remote-exec): SSH Agent: false
google_compute_instance.gitlab-ci-runner (remote-exec): Checking Host Key: false
google_compute_instance.gitlab-ci-runner (remote-exec): Connecting to remote host via SSH...
google_compute_instance.gitlab-ci-runner (remote-exec): Host:
google_compute_instance.gitlab-ci-runner (remote-exec): User: root
google_compute_instance.gitlab-ci-runner (remote-exec): Password: false
google_compute_instance.gitlab-ci-runner (remote-exec): Private key: false
google_compute_instance.gitlab-ci-runner (remote-exec): Certificate: false
google_compute_instance.gitlab-ci-runner (remote-exec): SSH Agent: false
google_compute_instance.gitlab-ci-runner (remote-exec): Checking Host Key: false
google_compute_instance.gitlab-ci-runner (remote-exec): Connecting to remote host via SSH...
Has anyone figured out how to use remote-exec provisioner with gce. I'm getting a known hosts key mismatch error when i try to do the same.
This got fixed some time ago. The connection
block now requires a host
specified and won't run without it.
connection {
host = self.network_interface.0.access_config.0.nat_ip
type = "ssh"
user = "provisioner"
private_key = "${file("${path.module}/keys/provisioner")}"
agent = false
timeout = "30s"
}
Terraform destroy:
google_compute_instance.test_machine: Destroying... [id=projects/iac-poc-krakow/zones/europe-west1-b/instances/test-machine]
google_compute_instance.test_machine: Provisioning with 'remote-exec'...
google_compute_instance.test_machine (remote-exec): Connecting to remote host via SSH...
google_compute_instance.test_machine (remote-exec): Host: 34.78.213.106
google_compute_instance.test_machine (remote-exec): User: provisioner
google_compute_instance.test_machine (remote-exec): Password: false
google_compute_instance.test_machine (remote-exec): Private key: true
google_compute_instance.test_machine (remote-exec): Certificate: false
google_compute_instance.test_machine (remote-exec): SSH Agent: false
google_compute_instance.test_machine (remote-exec): Checking Host Key: false
google_compute_instance.test_machine (remote-exec): Target Platform: unix
google_compute_instance.test_machine (remote-exec): Connected!
google_compute_instance.test_machine (remote-exec): destroy provisoner finished
@rileykarson I think this issue can be closed.
Community Note
Terraform Version
Terraform v0.11.13
Affected Resource(s)
Terraform Configuration Files
Debug Output
https://gist.github.com/franfran3/89e736c25200605055ce984bc47a32bb
Panic Output
Expected Behavior
At creation time:
terraform apply
should workterraform plan -out plan-file && terraform apply plan-file
should workAfter any modification that requires the instance destruction:
terraform apply
should workterraform plan -out plan-file && terraform apply plan-file
should workActual Behavior
At creation time:
terraform apply
worksterraform plan -out plan-file && terraform apply plan-file
worksAfter any modification that requires the instance destruction:
terraform apply
worksterraform plan -out plan-file && terraform apply plan-file
fails withssh: handshake failed: ssh: unable to authenticate
errorSteps to Reproduce
terraform plan -out plan-file
terraform apply plan-file
terraform plan -out plan-file
terraform apply plan-file
Important Factoids
After making modification, running
terraform plan -out plan-file && terraform apply plan-file
fails with the output of interest (the Host value is empty):while
terraform apply
is successful with the output of interest (the Host value is populated):A simple actual fix is to explicitly set the Host of the connection:
References
b/308756266