【发布时间】:2020-12-14 01:26:54
【问题描述】:
我知道容器优化操作系统主要是“noexec”。当我需要在我的主目录中执行一些简单的脚本,将文件从我的 docker 映像复制到主机等时,我有一个用例。当我使用 SSH 登录到实例时,这没有问题。但是使用 terraform 似乎不起作用:
resource "null_resource" "test_upload2" {
count = length(var.nodes)
provisioner "remote-exec" {
connection {
type = "ssh"
host = google_compute_address.static[count.index].address
private_key = file("keys/private_key")
user = var.admin_username
script_path = "/home/hyperledger/provision.sh"
}
inline = [
"ls"
]
}
depends_on = [google_compute_instance.peer-blockchain-vm, null_resource.test_upload]
}
我收到以下错误消息:
null_resource.test_upload[0] (remote-exec): bash: /home/hyperledger/provision.sh: Permission denied
Error: error executing "/home/hyperledger/provision.sh": Process exited with status 126
有没有办法纯粹使用 Terraform 来执行此操作? 将此逻辑外包给一些本地 shell 脚本并使用“local-exec”实现目标似乎不太好。
【问题讨论】:
标签: google-cloud-platform terraform terraform-provider-gcp