我定义了使用 Swift 管理 tfstate 的远程后端。
terraform {
backend "swift" {
container = "example"
}
}
运行“terraform init”后,有时会出现以下错误:
Do you want to copy existing state to the new backend?
Pre-existing state was found while migrating the previous "swift" backend to the
newly configured "swift" backend. An existing non-empty state already exists in
the new backend. The two states have been saved to temporary files that will be
removed after responding to this query.
Previous (type "swift"): /tmp/terraform704677678/1-swift.tfstate
New (type "swift"): /tmp/terraform704677678/2-swift.tfstate
Do you want to overwrite the state in the new backend with the previous state?
Enter "yes" to copy and "no" to start with the existing state in the newly
configured "swift" backend.
Enter a value:
由于需要意外的输入,这确实使 Terraform 的自动运行变得困难。
我需要 Ansible 仅对保存在容器中的远程 tfstate 进行操作,而不需要本地文件。
terraform init 任务完成后,没有 /tmp/terraform*。
提前感谢你的帮助。
答案1
看起来您正在使用两个状态文件。如果您确定它现在正在尝试使用正确的状态文件,则可以选择“是”,并让其将旧状态复制到新状态,这样就不会再出现此错误。
答案2
问题已在下一版本的 OpenStack 提供程序中得到修复。