@@ -6,18 +6,13 @@ locals {
66 ? " "
77 : var. storage_type == " ha" ? module. netapp . 0 . netapp_endpoint : module. nfs . 0 . private_ip_address
88 )
9+
910 rwx_filestore_path = (var. storage_type == " none"
1011 ? " "
1112 : var. storage_type == " ha" ? module. netapp . 0 . netapp_path : " /export"
1213 )
13- }
14-
15-
16- data "template_file" "jump-cloudconfig" {
17- template = file (" ${ path . module } /files/cloud-init/jump/cloud-config" )
18- count = var. create_jump_vm ? 1 : 0
1914
20- vars = {
15+ jump_cloudconfig = var . create_jump_vm ? templatefile ( " ${ path . module } /files/cloud-init/jump/cloud-config " , {
2116 mounts = (var.storage_type == " none"
2217 ? " []"
2318 : jsonencode (
@@ -33,18 +28,24 @@ data "template_file" "jump-cloudconfig" {
3328 rwx_filestore_path = local.rwx_filestore_path
3429 jump_rwx_filestore_path = var.jump_rwx_filestore_path
3530 vm_admin = var.jump_vm_admin
36- }
31+ }) : null
32+
33+ nfs_cloudconfig = var. storage_type == " standard" ? templatefile (" ${ path . module } /files/cloud-init/nfs/cloud-config" , {
34+ aks_cidr_block = module.vnet.subnets[" aks" ].address_prefixes.0
35+ misc_cidr_block = module.vnet.subnets[" misc" ].address_prefixes.0
36+ vm_admin = var.nfs_vm_admin
37+ }) : null
3738}
3839
39- data "template_cloudinit_config " "jump" {
40+ data "cloudinit_config " "jump" {
4041 count = var. create_jump_vm ? 1 : 0
4142
4243 gzip = true
4344 base64_encode = true
4445
4546 part {
4647 content_type = " text/cloud-config"
47- content = data . template_file . jump-cloudconfig . 0 . rendered
48+ content = local . jump_cloudconfig
4849 }
4950}
5051
@@ -63,32 +64,22 @@ module "jump" {
6364 vm_zone = var. jump_vm_zone
6465 fips_enabled = var. fips_enabled
6566 ssh_public_key = local. ssh_public_key
66- cloud_init = data. template_cloudinit_config . jump . 0 . rendered
67+ cloud_init = data. cloudinit_config . jump . 0 . rendered
6768 create_public_ip = var. create_jump_public_ip
6869
6970 # Jump VM mounts NFS path hence dependency on 'module.nfs'
7071 depends_on = [module . vnet , module . nfs ]
7172}
7273
73- data "template_file" "nfs-cloudconfig" {
74- template = file (" ${ path . module } /files/cloud-init/nfs/cloud-config" )
75- count = var. storage_type == " standard" ? 1 : 0
76- vars = {
77- aks_cidr_block = module.vnet.subnets[" aks" ].address_prefixes.0
78- misc_cidr_block = module.vnet.subnets[" misc" ].address_prefixes.0
79- vm_admin = var.nfs_vm_admin
80- }
81- }
82-
83- data "template_cloudinit_config" "nfs" {
74+ data "cloudinit_config" "nfs" {
8475 count = var. storage_type == " standard" ? 1 : 0
8576
8677 gzip = true
8778 base64_encode = true
8879
8980 part {
9081 content_type = " text/cloud-config"
91- content = data . template_file . nfs-cloudconfig . 0 . rendered
82+ content = local . nfs_cloudconfig
9283 }
9384}
9485
@@ -108,7 +99,7 @@ module "nfs" {
10899 vm_zone = var. nfs_vm_zone
109100 fips_enabled = var. fips_enabled
110101 ssh_public_key = local. ssh_public_key
111- cloud_init = data. template_cloudinit_config . nfs . 0 . rendered
102+ cloud_init = data. cloudinit_config . nfs . 0 . rendered
112103 create_public_ip = var. create_nfs_public_ip
113104 data_disk_count = 4
114105 data_disk_size = var. nfs_raid_disk_size
0 commit comments