gpt4 book ai didi

azure - 使用 cloudinit 创建 Terraform azurerm 虚拟机

转载 作者:行者123 更新时间:2023-12-05 08:06:19 29 4
gpt4 key购买 nike

尝试使用 cloudinit 创建虚拟机,但没有成功。terraform 上的文档没有提供如何在 Azure 上执行此操作的任何有用信息。找到这篇文章并尝试做同样的事情:
Using cloud-init on an Azure VM to mount a data disk fails
还尝试了 Terraform 文档:
https://www.terraform.io/docs/providers/template/d/cloudinit_config.html
每次我尝试时都会收到以下错误:
此处不需要名为“cloud_init_template”的参数。

此处不需要名为“user_data_base64”的参数。

带有相关代码的代码块:

provider "azurerm" {

version = "2.2.0"
features{}

}
#############################
# Cloud config configuration#
#############################
data "template_file" "cloudconfig" {
template = file("${path.module}/cloud-init.tpl")

vars {
timezone = var.timezone
password = data.azurerm_key_vault_secret.vaultsecret.value
tpot_flavor = var.tpot_flavor
web_user = var.web_user
web_password = var.web_password
}
}

data "template_cloudinit_config" "config" {
gzip = true
base64_encode = true

part {
content_type = "text/cloud-config"
content = data.template_file.cloudconfig.rendered
}
}

module "azure-vms" {

source = "./modules/azure-vms"
tpot_hostname = "${var.name}-Tpot"
location = azurerm_resource_group.rg.location
rg-name = azurerm_resource_group.rg.name
admin_password = data.azurerm_key_vault_secret.vaultsecret.value
cloud_init_template = data.template_cloudinit_config.config.rendered

}

我也对 user_data_base64 进行了相同的尝试
这是相同的错误消息。如果有人知道在 azure 上使用 cloudinit 部署虚拟机的正确方法是什么,我将不胜感激。

最佳答案

在VM资源提供者中使用云配置的正确方法是:

cloud_init_template = data.template_cloudinit_config.config.rendered

关于azure - 使用 cloudinit 创建 Terraform azurerm 虚拟机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61191641/

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