Forked from
Ryan Randles Jones / Terraform Openstack
112 commits ahead of the upstream repository.
-
Ravi Tripathi authored
1. Add a GitLab CD file to deploy the images created at [ohpc-packer](https://gitlab.rc.uab.edu/rc/ohpc-packer) via Terraform. 2. Use the existing routers and networks for Terraform deploy 3. Added a submodule for [CRI_Cluster_Monitor](https://github.com/eesaanatluri/CRI_Cluster_Monitor) and updated the existing one for [CRI_XCBC](https://github.com/jprorama/CRI_XCBC) 4. Refactored code to work with newer versions (>1.3) of terraform.
Ravi Tripathi authored1. Add a GitLab CD file to deploy the images created at [ohpc-packer](https://gitlab.rc.uab.edu/rc/ohpc-packer) via Terraform. 2. Use the existing routers and networks for Terraform deploy 3. Added a submodule for [CRI_Cluster_Monitor](https://github.com/eesaanatluri/CRI_Cluster_Monitor) and updated the existing one for [CRI_XCBC](https://github.com/jprorama/CRI_XCBC) 4. Refactored code to work with newer versions (>1.3) of terraform.
main.tf 1.76 KiB
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.42.0"
}
}
}
# is created as a datasource this module and called in root module
variable "public_network_name" {type = string}
variable "name" {default = "dmz"}
variable "admin_state_up" {}
variable "enable_dhcp" {}
data "openstack_networking_network_v2" "public_network" {name = var.public_network_name}
# creates dmznet
resource "openstack_networking_network_v2" "external_network" {
name = "${var.name}net"
admin_state_up = var.admin_state_up
}
resource "openstack_networking_subnet_v2" "external_subnet" {
name = "${var.name}subnet"
network_id = openstack_networking_network_v2.external_network.id
cidr = "192.168.100.0/24"
ip_version = 4
dns_nameservers = ["172.20.0.137", "172.20.0.3", "8.8.8.8"]
enable_dhcp = var.enable_dhcp
}
# defines the router dmzrouter using floating ip defined in datasource above to create the external network id
resource "openstack_networking_router_v2" "router" {
name = "${var.name}router"
admin_state_up = var.admin_state_up
external_network_id = data.openstack_networking_network_v2.public_network.id
}
resource "openstack_networking_router_interface_v2" "router" {
router_id = openstack_networking_router_v2.router.id
subnet_id = openstack_networking_subnet_v2.external_subnet.id
}
output "id" {
value = openstack_networking_network_v2.external_network.id
depends_on = [openstack_networking_subnet_v2.external_subnet]
}
output "external_subnet_id" {
value = openstack_networking_subnet_v2.external_subnet.id
}
output "router_id" {
value = openstack_networking_router_v2.router.id
}