2023-01-16 04:11:35 +03:00
locals {
2023-02-08 09:02:53 +03:00
data_disk_list = flatten ( [
for host_number in range ( var . nb_instances ) : [
for data _ disk_number in range ( var . nb_data_disk ) : {
2023-02-09 09:17:56 +03:00
key = join ( " - " , [ " datadisk " , host_number , data _ disk_number ] )
2023-02-13 12:51:02 +03:00
name = replace ( replace ( replace ( var . name_template_data_disk , " $ ${ vm_hostname } " , var . vm_hostname ) , " $ ${ host_number } " , host_number ) , " $ ${ data _ disk_number } " , data _ disk_number )
2023-02-08 09:02:53 +03:00
host_number = host_number
disk_number = data _ disk_number
}
]
] )
2023-02-09 09:17:56 +03:00
data_disk_map = { for obj in local . data _ disk_list : obj . key => obj if ! var . nested_data_disks }
data_disk_map_linux = { for obj in local . data _ disk_list : obj . key => obj if ! var . nested_data_disks && ! local . is_windows }
data_disk_map_windows = { for obj in local . data _ disk_list : obj . key => obj if ! var . nested_data_disks && local . is_windows }
2023-02-08 09:02:53 +03:00
extra_disk_list = flatten ( [
for host_number in range ( var . nb_instances ) : [
for extra_disk in var . extra_disks : {
2023-02-09 09:17:56 +03:00
key = join ( " - " , [ " extradisk " , host_number , extra_disk . name ] )
2023-02-13 12:51:02 +03:00
name = replace ( replace ( replace ( var . name_template_extra_disk , " $ ${ vm_hostname } " , var . vm_hostname ) , " $ ${ host_number } " , host_number ) , " $ ${ extra_disk_name } " , extra_disk . name )
2023-02-08 09:02:53 +03:00
host_number = host_number
disk_number = index ( var . extra_disks , extra_disk )
disk_name = extra_disk . name
disk_size = extra_disk . size
}
]
] )
2023-02-09 09:17:56 +03:00
extra_disk_map = { for obj in local . extra_disk_list : obj . key => obj if ! var . nested_data_disks }
extra_disk_map_linux = { for obj in local . extra_disk_list : obj . key => obj if ! var . nested_data_disks && ! local . is_windows }
extra_disk_map_windows = { for obj in local . extra_disk_list : obj . key => obj if ! var . nested_data_disks && local . is_windows }
is_windows = ( var . is_windows_image | | contains ( tolist ( [ var . vm_os_simple , var . vm_os_offer ] ) , " WindowsServer " ) ) | | var . is_windows_image == true
nested_data_disk_list = var . nested_data_disks ? range ( var . nb_data_disk ) : [ ]
nested_extra_data_disk_list = var . nested_data_disks ? var . extra_disks : [ ]
vm_extensions = { for p in setproduct ( toset ( [ for e in var . vm_extensions : e ] ) , toset ( range ( var . nb_instances ) ) ) : " ${ p [ 0 ] . name } - ${ p [ 1 ] } " => { index = p [ 1 ] , value = p [ 0 ] } }
2023-01-16 04:11:35 +03:00
}