我正在尝试创建一个VMSS,并希望使用Packer捆绑我的图像和Terraform来创建Azure基础设施的其余部分。
我正在本地测试,但最终将推送到DevOps。当我尝试应用我的terraform时,我得到以下错误:
Error: local-exec provisioner error
│
│ with null_resource.packer,
│ on main.tf line 14, in resource "null_resource" "packer":
│ 14: provisioner "local-exec" {
│
│ Error running command 'packer build \
│ -var client_id=[client] \
│ -var client_secret=[secret] \
│ -var install_password=CHANGEME! \
│ -var location=UKSOUTH \
│ -var resource_group=[resourcegroup] \
│ -var storage_account=[sa] \
│ -var subscription_id=[sub] \
│ -var temp_resource_group_name=rg-packerbuild-test \
│ -var tenant_id=[tenant] \
│ -var virtual_network_name=[vnet] \
│ -var virtual_network_resource_group_name=[resource group] \
│ -var virtual_network_subnet_name=hosts \
│ windows2022.pkr.json
│ ': exit status 1. Output: Error: Could not find any config file in \
│
│ A config file must be suffixed with `.pkr.hcl` or `.pkr.json`. A folder can be
│ referenced.
locals {
ami_name = join("-", [var.name, formatdate("YYYYMMDDhhmmss", timestamp())])
}
resource "null_resource" "packer" {
triggers = {
ami_name = local.ami_name
}
provisioner "local-exec" {
working_dir = path.module
command = <<-EOF
packer build \
-var client_id=${var.client_id} \
-var client_secret=${var.client_secret} \
-var install_password=${var.install_password} \
-var location=${var.location} \
-var resource_group=${var.resource_group} \
-var storage_account=${var.storage_account} \
-var subscription_id=${var.SubscriptionId} \
-var temp_resource_group_name=${var.TempResourceGroupName} \
-var tenant_id=${var.TenantId} \
-var virtual_network_name=${var.VirtualNetworkName} \
-var virtual_network_resource_group_name=${var.VirtualNetworkRG} \
-var virtual_network_subnet_name=${var.VirtualNetworkSubnet} \
windows2022.pkr.json
EOF
}
}
文件就在那里,我在packer build
命令之前添加了dir
命令,它列出了正确的文件路径。
你知道我做错了什么吗?
谢谢
1条答案
按热度按时间siv3szwd1#
我通过添加
interpreter
命令并更改\
来修复它。希望这对某人有帮助。