Open camscale opened 3 years ago
Hello, I have the same problem when trying to create droplet and after set password for user.
resource "digitalocean_droplet" "test" {
count = var.number_of_vps
image = "ubuntu-18-04-x64"
name = "kamorozov-test-1"
region = data.digitalocean_regions.available.regions[0].slug
size = "s-1vcpu-1gb"
ssh_keys = [data.digitalocean_ssh_keys.rebrain_key.ssh_keys[0].id, digitalocean_ssh_key.kamorozov.id]
tags = ["devops", local.email_for_tag]
connection {
type = "ssh"
host = self.ipv4_address
# private_key = file(var.path_to_personal_private_key)
}
provisioner "remote-exec" {
inline = [
# "echo \"root:${var.root_pwd}\" | sudo chpasswd"
"cat /etc/os-*"
]
}
}
│ Error: remote-exec provisioner error
│
│ with digitalocean_droplet.test[1],
│ on main.tf line 68, in resource "digitalocean_droplet" "test":
│ 68: provisioner "remote-exec" {
│
│ Error connecting to SSH_AUTH_SOCK: dial unix
│ /private/tmp/com.apple.launchd.N8U5ixswMY/Listeners: connect: no such file
│ or directory
╵
╷
│ Error: remote-exec provisioner error
│
│ with digitalocean_droplet.test[0],
│ on main.tf line 68, in resource "digitalocean_droplet" "test":
│ 68: provisioner "remote-exec" {
│
│ Error connecting to SSH_AUTH_SOCK: dial unix
│ /private/tmp/com.apple.launchd.N8U5ixswMY/Listeners: connect: no such file
│ or directory
What is wrong?
I tried restarting macbook and magically it started working.
I added agent = false
to get it working.
connection {
type = "ssh"
host = self.public_ip
user = "xxx"
agent = false
private_key = file("xxx.pem")
timeout = "4m"
}
When using the file provisioner with an SSH connection, terraform will attempt to connect to the ssh-agent specified in
$SSH_AUTH_SOCK
even if the private key is provided via theprivate_key
field of theprovisioner.connection
block. Sometimes my$SSH_AUTH_SOCK
is invalid (I have reconnected to a tmux session from elsewhere), but this should make no difference as the private key (unencrypted) is explicitly provided and not in the ssh-agent keystore.If I unset the
$SSH_AUTH_SOCK
environment variable, terraform successfully provisions the file via ssh.Terraform Version
Terraform Configuration Files
Debug Output
Expected Behavior
Terraform should use the provided ssh key in the provider block and not try to connect to the ssh-agent specified in
$SSH_AUTH_SOCK
.Actual Behavior
Terraform fails to provision a file using the file provisioner and exits with an error.
Steps to Reproduce