Skip to content

Commit 67b7e5d

Browse files
authored
Merge pull request #18 from stackhpc/dns-for-fixed-ipv4
feat: optionally create A records for labs
2 parents b9b34ba + 6b8ce70 commit 67b7e5d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

openstack-device.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,20 @@ resource "openstack_compute_secgroup_v2" "AUFN" {
157157
}
158158
}
159159

160+
data "openstack_dns_zone_v2" "lab_zone" {
161+
count = var.dns_zone_name != null ? 1 : 0
162+
name = var.dns_zone_name
163+
}
164+
165+
resource "openstack_dns_recordset_v2" "lab_dns" {
166+
count = var.dns_zone_name != null ? var.lab_count : 0
167+
zone_id = data.openstack_dns_zone_v2.lab_zone[0].id
168+
name = format("%s-lab-%02d.%s", var.lab_prefix, count.index, var.dns_zone_name)
169+
type = "A"
170+
ttl = 300
171+
records = [openstack_compute_instance_v2.lab[count.index].network[0].fixed_ip_v4]
172+
}
173+
160174
resource "openstack_compute_instance_v2" "lab" {
161175

162176
count = var.lab_count

vars.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,10 @@ variable "bastion_floating_ip" {
7979
description = "Bastion floating IP"
8080
default = "0.0.0.0"
8181
}
82+
83+
variable "dns_zone_name" {
84+
description = "The name of the DNS zone to use for creating DNS records. Leave null to skip DNS record creation."
85+
type = string
86+
nullable = true
87+
default = null
88+
}

0 commit comments

Comments
 (0)