|
1 | | -data "template_file" "network_config" { |
2 | | - count = var.vm_count |
3 | | - template = file("${path.module}/templates/network_config_${var.dhcp == true ? "dhcp" : "static"}.tpl") |
4 | | - vars = { |
5 | | - ip_address = element(var.ip_address, count.index) |
6 | | - ip_gateway = var.ip_gateway |
7 | | - ip_nameserver = var.ip_nameserver |
8 | | - nic = (var.share_filesystem.source == null ? "ens3" : "ens4") |
9 | | - # WA: If the shared filesystem is used, Libvirt connects Unclassified device to the 3rd position of PCI bus |
10 | | - } |
11 | | -} |
12 | | - |
13 | | -data "template_file" "init_config" { |
14 | | - count = var.vm_count |
15 | | - template = file("${path.module}/templates/cloud_init.tpl") |
16 | | - vars = { |
17 | | - ssh_admin = var.ssh_admin |
18 | | - ssh_keys = local.all_keys |
19 | | - local_admin = var.local_admin |
20 | | - local_admin_passwd = var.local_admin_passwd |
21 | | - hostname = format("${var.vm_hostname_prefix}%02d", count.index + var.index_start) |
22 | | - time_zone = var.time_zone |
23 | | - runcmd = local.runcmd |
24 | | - } |
25 | | -} |
26 | | - |
27 | 1 | locals { |
28 | 2 | all_keys = <<EOT |
29 | 3 | [ |
|
39 | 13 | EOT |
40 | 14 | } |
41 | 15 |
|
42 | | -data "template_cloudinit_config" "init_config" { |
| 16 | +data "cloudinit_config" "init_config" { |
43 | 17 | count = var.vm_count |
44 | 18 | gzip = false |
45 | 19 | base64_encode = false |
46 | 20 |
|
47 | 21 | part { |
48 | 22 | filename = format("init%02d.cfg", count.index + var.index_start) |
49 | 23 | content_type = "text/cloud-config" |
50 | | - content = data.template_file.init_config[count.index].rendered |
| 24 | + content = templatefile( |
| 25 | + "${path.module}/templates/cloud_init.tpl", |
| 26 | + { |
| 27 | + ssh_admin = var.ssh_admin |
| 28 | + ssh_keys = local.all_keys |
| 29 | + local_admin = var.local_admin |
| 30 | + local_admin_passwd = var.local_admin_passwd |
| 31 | + hostname = format("${var.vm_hostname_prefix}%02d", count.index + var.index_start) |
| 32 | + time_zone = var.time_zone |
| 33 | + runcmd = local.runcmd |
| 34 | + } |
| 35 | + ) |
51 | 36 | } |
52 | 37 | } |
0 commit comments