|
12 | 12 |
|
13 | 13 | locals { |
14 | 14 | nodename = var.nodename == "" ? var.name_prefix : var.nodename |
15 | | - # address = libvirt_domain.node.network_interface[0].addresses[0] |
| 15 | + address = libvirt_domain.node.network_interface[0].addresses[0] |
16 | 16 | use_generated_keypair = var.ssh_private_key == "" || var.ssh_public_key == "" |
17 | 17 | ssh_public_key = local.use_generated_keypair ? tls_private_key.keypair[0].public_key_openssh : var.ssh_public_key |
18 | 18 | ssh_private_key = local.use_generated_keypair ? tls_private_key.keypair[0].private_key_openssh : var.ssh_private_key |
@@ -52,48 +52,48 @@ resource "libvirt_volume" "root" { |
52 | 52 | size = 21474836480 |
53 | 53 | } |
54 | 54 |
|
55 | | -# resource "libvirt_domain" "node" { |
56 | | -# name = var.name_prefix |
57 | | -# machine = "q35" |
58 | | -# cloudinit = libvirt_cloudinit_disk.ci.id |
59 | | -# memory = 2048 |
60 | | -# vcpu = 2 |
61 | | -# qemu_agent = true |
62 | | -# xml { |
63 | | -# xslt = file("${path.module}/libvirt-domain.xsl") |
64 | | -# } |
65 | | -# cpu { |
66 | | -# mode = "host-passthrough" |
67 | | -# } |
68 | | -# disk { |
69 | | -# volume_id = libvirt_volume.root.id |
70 | | -# scsi = true |
71 | | -# } |
72 | | -# network_interface { |
73 | | -# network_name = var.libvirt_network_name |
74 | | -# hostname = local.nodename |
75 | | -# wait_for_lease = true |
76 | | -# } |
77 | | -# console { |
78 | | -# type = "pty" |
79 | | -# target_port = "0" |
80 | | -# target_type = "serial" |
81 | | -# } |
82 | | -# provisioner "remote-exec" { |
83 | | -# inline = [ |
84 | | -# "cloud-init status --wait", |
85 | | -# templatefile("${path.module}/provision/setup-hostname.sh.tftpl", { |
86 | | -# hostname = local.nodename |
87 | | -# ipv4 = self.network_interface[0].addresses[0] |
88 | | -# }), |
89 | | -# file("${path.module}/provision/install-pve.sh"), |
90 | | -# file("${path.module}/provision/setup-interfaces-sdn.sh") |
91 | | -# ] |
92 | | -# connection { |
93 | | -# type = "ssh" |
94 | | -# user = "debian" |
95 | | -# private_key = local.ssh_private_key |
96 | | -# host = self.network_interface[0].addresses[0] |
97 | | -# } |
98 | | -# } |
99 | | -# } |
| 55 | +resource "libvirt_domain" "node" { |
| 56 | + name = var.name_prefix |
| 57 | + machine = "q35" |
| 58 | + cloudinit = libvirt_cloudinit_disk.ci.id |
| 59 | + memory = 2048 |
| 60 | + vcpu = 2 |
| 61 | + qemu_agent = true |
| 62 | + xml { |
| 63 | + xslt = file("${path.module}/libvirt-domain.xsl") |
| 64 | + } |
| 65 | + cpu { |
| 66 | + mode = "host-passthrough" |
| 67 | + } |
| 68 | + disk { |
| 69 | + volume_id = libvirt_volume.root.id |
| 70 | + scsi = true |
| 71 | + } |
| 72 | + network_interface { |
| 73 | + network_name = var.libvirt_network_name |
| 74 | + hostname = local.nodename |
| 75 | + wait_for_lease = true |
| 76 | + } |
| 77 | + console { |
| 78 | + type = "pty" |
| 79 | + target_port = "0" |
| 80 | + target_type = "serial" |
| 81 | + } |
| 82 | + provisioner "remote-exec" { |
| 83 | + inline = [ |
| 84 | + "cloud-init status --wait", |
| 85 | + templatefile("${path.module}/provision/setup-hostname.sh.tftpl", { |
| 86 | + hostname = local.nodename |
| 87 | + ipv4 = self.network_interface[0].addresses[0] |
| 88 | + }), |
| 89 | + file("${path.module}/provision/install-pve.sh"), |
| 90 | + file("${path.module}/provision/setup-interfaces-sdn.sh") |
| 91 | + ] |
| 92 | + connection { |
| 93 | + type = "ssh" |
| 94 | + user = "debian" |
| 95 | + private_key = local.ssh_private_key |
| 96 | + host = self.network_interface[0].addresses[0] |
| 97 | + } |
| 98 | + } |
| 99 | +} |
0 commit comments