【发布时间】:2020-10-04 20:13:42
【问题描述】:
这篇文章有一个远程执行的解决方案:How can I start a remote service using Terraform provisioning?
我正在尝试对 local-exec 供应商做同样的事情。
我需要在远程节点上打开 ssh 隧道:
#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"]
}
隧道已创建,但 Terraform 不会继续下一步。
如果我将 ssh 命令替换为:
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};
有什么想法吗?
【问题讨论】:
标签: terraform