标签: terraform-provider-vsphere

使用 Terraform 创建多个新实例

我编写了一个 Terraform 脚本,该脚本应该从一个模板创建多个服务器实例。我现在创建了两个不同的变量文件。

但是当我运行脚本时,会使用第一个变量文件创建一个新实例,但使用第二个变量文件时,第一个实例始终会被覆盖/更改。我不知道为什么 Terraform 引用之前新创建的实例。我怎样才能防止这种情况发生?

服务器1.tfvars:

vsphere_user                     = "administrator@vsphere.local"
vsphere_password                 = "#Password"
vsphere_server                   = "vsphere.server"
vsphere_datacenter               = "Datacenter"
vsphere_datastore                = "Storage_1"
vsphere_compute_cluster          = "Cluster"
vsphere_network                  = "Network_1"
vsphere_virtual_machine_template = "Template_Microsoft_Windows_Server_2019_x64_english"
system_name                      = "server-1"
system_cores                     = 2
system_cores_per_socket          = 2
system_memory                    = 2048
system_local_admin_password      = "#Password"
system_ipv4_address              = "172.22.15.11"
system_ipv4_netmask              = 24
system_dns_server_list           = ["172.22.15.101"]
system_ipv4_gateway              = "172.22.15.1"
system_disk1_size                = 75
system_domain_admin_user         = "Administrator"
system_domain_admin_password     = "#Password"
Run Code Online (Sandbox Code Playgroud)

服务器2.tfvars:

vsphere_user                     = "administrator@vsphere.local"
vsphere_password                 = "#Password"
vsphere_server                   = "vsphere.server"
vsphere_datacenter               = "Datacenter" …
Run Code Online (Sandbox Code Playgroud)

vsphere terraform terraform-provider-vsphere

1
推荐指数
1
解决办法
4554
查看次数