feat: add variable for configuring public DNS upstreams on subnets

This commit is contained in:
Bertrand Lanson 2024-04-14 00:24:12 +02:00
parent 0f61134f89
commit 98594d22b9
3 changed files with 37 additions and 35 deletions

View File

@ -63,6 +63,7 @@ No modules.
| <a name="input_project_domain"></a> [project_domain](#input_project_domain) | The domain where this project will be created | `string` | `"default"` | no | | <a name="input_project_domain"></a> [project_domain](#input_project_domain) | The domain where this project will be created | `string` | `"default"` | no |
| <a name="input_project_name"></a> [project_name](#input_project_name) | The name of the project | `string` | n/a | yes | | <a name="input_project_name"></a> [project_name](#input_project_name) | The name of the project | `string` | n/a | yes |
| <a name="input_project_tags"></a> [project_tags](#input_project_tags) | The tags to append to this project | `list(string)` | `[]` | no | | <a name="input_project_tags"></a> [project_tags](#input_project_tags) | The tags to append to this project | `list(string)` | `[]` | no |
| <a name="input_public_nameservers"></a> [public_nameservers](#input_public_nameservers) | A list of public DNS servers to upstreams requests to in your subnets.<br>This is not necessary if your openstack deployment already has configured default upstreams for neutron. | `list(string)` | `[]` | no |
| <a name="input_public_subnetpool_id"></a> [public_subnetpool_id](#input_public_subnetpool_id) | The id of the subnetpool to create the public (first 2 tier) networks from.<br>Since this module can route private subnets to the backbone, it needs to make sure it's not creating overlapping subnets. | `string` | `null` | no | | <a name="input_public_subnetpool_id"></a> [public_subnetpool_id](#input_public_subnetpool_id) | The id of the subnetpool to create the public (first 2 tier) networks from.<br>Since this module can route private subnets to the backbone, it needs to make sure it's not creating overlapping subnets. | `string` | `null` | no |
| <a name="input_subnetpool_cidr_blocks"></a> [subnetpool_cidr_blocks](#input_subnetpool_cidr_blocks) | The CIDR block for the subnet pool | `list(string)` | <pre>[<br> "192.168.0.0/21"<br>]</pre> | no | | <a name="input_subnetpool_cidr_blocks"></a> [subnetpool_cidr_blocks](#input_subnetpool_cidr_blocks) | The CIDR block for the subnet pool | `list(string)` | <pre>[<br> "192.168.0.0/21"<br>]</pre> | no |

View File

@ -66,6 +66,7 @@ resource "openstack_networking_subnet_v2" "frontend" {
prefix_length = var.frontend_subnet_prefix_len prefix_length = var.frontend_subnet_prefix_len
ip_version = 4 ip_version = 4
subnetpool_id = var.create_subnetpool ? openstack_networking_subnetpool_v2.this[0].id : var.public_subnetpool_id subnetpool_id = var.create_subnetpool ? openstack_networking_subnetpool_v2.this[0].id : var.public_subnetpool_id
dns_nameservers = var.public_nameservers
} }
resource "openstack_networking_subnet_v2" "backend" { resource "openstack_networking_subnet_v2" "backend" {
@ -77,6 +78,7 @@ resource "openstack_networking_subnet_v2" "backend" {
prefix_length = var.backend_subnet_prefix_len prefix_length = var.backend_subnet_prefix_len
ip_version = 4 ip_version = 4
subnetpool_id = var.create_subnetpool ? openstack_networking_subnetpool_v2.this[0].id : var.public_subnetpool_id subnetpool_id = var.create_subnetpool ? openstack_networking_subnetpool_v2.this[0].id : var.public_subnetpool_id
dns_nameservers = var.public_nameservers
} }
resource "openstack_networking_subnet_v2" "database" { resource "openstack_networking_subnet_v2" "database" {
@ -88,6 +90,7 @@ resource "openstack_networking_subnet_v2" "database" {
prefix_length = var.database_subnet_prefix_len prefix_length = var.database_subnet_prefix_len
ip_version = 4 ip_version = 4
subnetpool_id = var.create_subnetpool ? openstack_networking_subnetpool_v2.this[0].id : var.database_subnetpool_id subnetpool_id = var.create_subnetpool ? openstack_networking_subnetpool_v2.this[0].id : var.database_subnetpool_id
dns_nameservers = var.public_nameservers
} }
#! router #! router

View File

@ -100,6 +100,15 @@ variable "database_subnet_prefix_len" {
} }
} }
variable "public_nameservers" {
type = list(string)
description = <<-EOT
A list of public DNS servers to upstreams requests to in your subnets.
This is not necessary if your openstack deployment already has configured default upstreams for neutron.
EOT
default = []
}
#! security variables #! security variables
variable "create_default_secgroups" { variable "create_default_secgroups" {
type = bool type = bool
@ -191,21 +200,10 @@ variable "external_network_id" {
default = null default = null
} }
# variable "external_subnet_id" {
# type = string
# description = "The id of the external subnet to connect the frontend router to."
# default = null
# }
locals { locals {
validate_external_network_id = ( validate_external_network_id = (
var.architecture_tiers > 0 && var.architecture_tiers > 0 &&
var.attach_to_external && var.attach_to_external &&
var.external_network_id == null var.external_network_id == null
) ? tobool("Please pass in the external network ID to attach the frontend router to.") : true ) ? tobool("Please pass in the external network ID to attach the frontend router to.") : true
# validate_external_subnet_id = (
# var.architecture_tiers > 0 &&
# var.attach_to_external &&
# var.external_subnet_id == null
# ) ? tobool("Please pass in the external subnet ID to attach the frontend router to.") : true
} }