This post has a solution for remote-exec : How can I start a remote service using Terraform provisioning?
I am trying to do the same with local-exec provisioner.
I need to open ssh tunnel on remote node:
#create remote SSH reverse tunnel
provisioner "local-exec" {
command = <<EOT
ssh-keygen -f "$HOME/.ssh/known_hosts" -R "${self.ip}";
nohup ssh -oStrictHostKeyChecking=no -N -R ${var.chef_zero_port}:localhost:${var.chef_zero_port} ${var.ssh_username}@${self.ip} -M -S /tmp/.ssh_to_${self.ip} &
sleep 2
EOT
interpreter = ["/bin/bash","-c"]
}
tunnel is created but Terraform does not move on to next step.
same if I replace ssh command with:
ssh -oStrictHostKeyChecking=no -fN -R ${var.chef_zero_port}:localhost:${var.chef_zero_port} ${var.ssh_username}@${self.ip} -M -S /tmp/.ssh_to_${self.ip};
any ideas?