gpt4 book ai didi

ssl - terraform provisioner - 本地 exec bin/sh 目录不存在错误

转载 作者:行者123 更新时间:2023-12-04 22:39:37 25 4
gpt4 key购买 nike

使用 terraform 为 hash Vault 创建一些自签名 tlf 证书,我的模块中主要有问题的 terraform 位如下,我尝试了 2 种方法来让它工作。
第一种方式,理论上,我认为应该可行:

      provisioner "local-exec" {
command = "echo '${self.cert_pem}' > ../tls/ca.pem && chmod 0600 ../tls/ca.pem"
}
}

provisioner "local-exec" {
command = "echo '${self.cert_pem}' > ../tls/vault.pem && echo '${tls_self_signed_cert.vault-ca.cert_pem}' >> ../tls/vault.pem && chmod 0600 ../tls/vault.pem"
}
引发此错误:
│ ' > ../tls/ca.pem && chmod 0600 ../tls/ca.pem': exit status 2. Output:
│ /bin/sh: 1: cannot create ../tls/ca.pem: Directory nonexistent
如果我将 .. 替换为硬编码路径,即:
      provisioner "local-exec" {
command = "echo '${self.cert_pem}' > /etc/vault/tls/ca.pem && chmod 0600 /etc/vault/tls/ca.pem"
}
}

provisioner "local-exec" {
command = "echo '${self.cert_pem}' > /etc/vault/tls/vault.pem && echo '${tls_self_signed_cert.vault-ca.cert_pem}' >> /etc/vault/tls/vault.pem && chmod 0600 /etc/vault/tls/vault.pem"
}
我得到了同样的错误,但显然显示了路径:
> /etc/vault/tls/ca.pem && chmod 0600 /etc/vault/tls/ca.pem': exit status
│ 2. Output: /bin/sh: 1: cannot create /etc/vault/tls/ca.pem: Directory
│ nonexistent
如果我继续查看自己的容器,路径/etc/vault/tls 就在那里......

最佳答案

您必须确保 /etc/vault/tls/在您将文件写入其中之前存在:

 provisioner "local-exec" {
command = "sudo mkdir -p /etc/vault/tls && sudo echo '${self.cert_pem}' > /etc/vault/tls/ca.pem && sudo chmod 0600 /etc/vault/tls/ca.pem"
}

关于ssl - terraform provisioner - 本地 exec bin/sh 目录不存在错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71393732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com