diff --git a/juju/home-maas-jammy/04-openstack-common.tf b/juju/home-maas-jammy/04-openstack-common.tf index 133c1ca..6891fef 100644 --- a/juju/home-maas-jammy/04-openstack-common.tf +++ b/juju/home-maas-jammy/04-openstack-common.tf @@ -52,6 +52,26 @@ module "glance" { rabbitmq-server_app = module.rabbitmq-server.rabbitmq-server.name } +module "placement" { + source = "./modules/placement" + + # Placement variables + placement-channel = var.openstack-channel + + # Common variables + vips = var.vips + controller_ids = var.controller_ids + all_machines = juju_machine.all_machines + model-name = var.model-name + public-space = var.public-space + internal-space = var.internal-space + admin-space = var.admin-space + + # Dependancies + keystone_app = module.keystone.keystone.name + novacc_app = juju_application.nova-cloud-controller.name +} + module "heat" { source = "./modules/heat" @@ -266,3 +286,16 @@ module "vault" { # Dependancies ceph-osd_app = juju_application.ceph-osd.name } + +module "memcached" { + source = "./modules/memcached" + + # Common variables + controller_ids = var.controller_ids + all_machines = juju_machine.all_machines + model-name = var.model-name + + # Dependancies + novacc_app = juju_application.nova-cloud-controller.name +} + diff --git a/juju/home-maas-jammy/modules/cinder-ceph/main.tf b/juju/home-maas-jammy/modules/cinder-ceph/main.tf index bfd2909..73f4bf2 100644 --- a/juju/home-maas-jammy/modules/cinder-ceph/main.tf +++ b/juju/home-maas-jammy/modules/cinder-ceph/main.tf @@ -10,6 +10,7 @@ resource "juju_application" "cinder-ceph" { config = { restrict-ceph-pools = "false" + rbd-pool-name = var.ceph-pool==""? null : var.ceph-pool } } diff --git a/juju/home-maas-jammy/modules/memcached/init.tf b/juju/home-maas-jammy/modules/memcached/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/memcached/init.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + juju = { + version = "~> 0.19.0" + source = "registry.terraform.io/juju/juju" + } + } +} diff --git a/juju/home-maas-jammy/05-memcache.tf b/juju/home-maas-jammy/modules/memcached/main.tf similarity index 58% rename from juju/home-maas-jammy/05-memcache.tf rename to juju/home-maas-jammy/modules/memcached/main.tf index 397e0e3..f37d69f 100644 --- a/juju/home-maas-jammy/05-memcache.tf +++ b/juju/home-maas-jammy/modules/memcached/main.tf @@ -1,23 +1,23 @@ -resource "juju_machine" "memcache" { +resource "juju_machine" "memcached" { count = var.num_units model = var.model-name - placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids[count.index]].machine_id]) + placement = join(":", ["lxd", var.all_machines[var.controller_ids[count.index]].machine_id]) constraints = "spaces=oam" } resource "juju_application" "memcached" { - name = "memcached" + name = var.app-name model = var.model-name charm { name = "memcached" - channel = "latest/stable" + channel = var.memcache-channel base = var.default-base } machines = [ - for res in juju_machine.memcache : + for res in juju_machine.memcached : res.machine_id ] @@ -29,17 +29,15 @@ resource "juju_application" "memcached" { space = var.internal-space }] - config = { - allow-ufw-ip6-softfail = "true" - } + config = local.memcached-config } -resource "juju_integration" "nova-cloud-controller-memcache" { +resource "juju_integration" "nova-cc-memcached" { model = var.model-name application { - name = juju_application.nova-cloud-controller.name + name = var.novacc_app endpoint = "memcache" } diff --git a/juju/home-maas-jammy/modules/memcached/outputs.tf b/juju/home-maas-jammy/modules/memcached/outputs.tf new file mode 100644 index 0000000..69a1dc2 --- /dev/null +++ b/juju/home-maas-jammy/modules/memcached/outputs.tf @@ -0,0 +1,3 @@ +output "memcached" { + value = juju_application.memcached +} diff --git a/juju/home-maas-jammy/modules/memcached/variables.tf b/juju/home-maas-jammy/modules/memcached/variables.tf new file mode 100644 index 0000000..0be77f5 --- /dev/null +++ b/juju/home-maas-jammy/modules/memcached/variables.tf @@ -0,0 +1,88 @@ +variable num_units { + type = number + default = 3 +} + +variable "all_machines" { + description = "Machines" + type = map(object({ + base = string + constraints = string + id = string + machine_id = string + model = string + name = string + series = string + })) +} + +variable controller_ids { + type = list(string) + default = [] +} + +variable model-name { + type = string + default = "openstack" +} + +variable default-base { + type = string + default = "ubuntu@22.04" +} + +variable default-series { + type = string + default = "jammy" +} + +variable memcache-channel { + type = string + default = "latest/stable" +} + +variable memcache-revision { + type = string + default = "" +} + +variable oam-space { + type = string + default = "oam" +} + +variable admin-space { + type = string + default = "admin" +} + +variable internal-space { + type = string + default = "internal" +} + +variable app-name { + type = string + default = "memcached" +} + +variable novacc_app { + type = string + default = "nova-cloud-controller" +} + +variable memcached-config-overrides { + type = map(string) + default = {} +} + +locals { + base-memcached-config = { + allow-ufw-ip6-softfail = "true" + } + + memcached-config = merge( + local.base-memcached-config, + var.memcached-config-overrides + ) +} diff --git a/juju/home-maas-jammy/modules/placement/init.tf b/juju/home-maas-jammy/modules/placement/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/placement/init.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + juju = { + version = "~> 0.19.0" + source = "registry.terraform.io/juju/juju" + } + } +} diff --git a/juju/home-maas-jammy/05-placement.tf b/juju/home-maas-jammy/modules/placement/main.tf similarity index 60% rename from juju/home-maas-jammy/05-placement.tf rename to juju/home-maas-jammy/modules/placement/main.tf index 998f5aa..2793162 100644 --- a/juju/home-maas-jammy/05-placement.tf +++ b/juju/home-maas-jammy/modules/placement/main.tf @@ -1,18 +1,18 @@ resource "juju_machine" "placement" { count = var.num_units model = var.model-name - placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids[count.index+var.num_units]].machine_id]) + placement = join(":", ["lxd", var.all_machines[var.controller_ids[count.index+var.num_units]].machine_id]) constraints = "spaces=oam" } resource "juju_application" "placement" { - name = "placement" + name = var.app-name model = var.model-name charm { name = "placement" - channel = var.openstack-channel + channel = var.placement-channel base = var.default-base } @@ -37,29 +37,21 @@ resource "juju_application" "placement" { space = var.internal-space }] - config = { - worker-multiplier = var.worker-multiplier - openstack-origin = var.openstack-origin - vip = var.vips["placement"] - #os-admin-hostname = "${join(".",[var.fqdn-admin["placement"],var.domain])}" - #os-internal-hostname = "${join(".",[var.fqdn-int["placement"],var.domain])}" - #os-public-hostname = "${join(".",[var.fqdn-pub["placement"],var.domain])}" - - } + config = local.placement-config } module "placement-mysql-router" { - source = "./modules/mysql-router" + source = "../mysql-router" sub-name = juju_application.placement.name - model-name = juju_model.openstack.name + model-name = var.model-name } module "placement-hacluster" { - source = "./modules/hacluster" + source = "../hacluster" sub-name = juju_application.placement.name - model-name = juju_model.openstack.name + model-name = var.model-name } resource "juju_integration" "placement-keystone" { @@ -72,7 +64,7 @@ resource "juju_integration" "placement-keystone" { } application { - name = module.keystone.keystone.name + name = var.keystone_app endpoint = "identity-service" } } @@ -87,7 +79,7 @@ resource "juju_integration" "placement-nova" { } application { - name = juju_application.nova-cloud-controller.name + name = var.novacc_app endpoint = "placement" } } diff --git a/juju/home-maas-jammy/modules/placement/outputs.tf b/juju/home-maas-jammy/modules/placement/outputs.tf new file mode 100644 index 0000000..0a3c4f8 --- /dev/null +++ b/juju/home-maas-jammy/modules/placement/outputs.tf @@ -0,0 +1,3 @@ +output "placement" { + value = juju_application.placement +} diff --git a/juju/home-maas-jammy/modules/placement/variables.tf b/juju/home-maas-jammy/modules/placement/variables.tf new file mode 100644 index 0000000..314d90f --- /dev/null +++ b/juju/home-maas-jammy/modules/placement/variables.tf @@ -0,0 +1,135 @@ +variable num_units { + type = number + default = 3 +} + +variable "all_machines" { + description = "Machines" + type = map(object({ + base = string + constraints = string + id = string + machine_id = string + model = string + name = string + series = string + })) +} + +variable controller_ids { + type = list(string) + default = [] +} + +variable model-name { + type = string + default = "openstack" +} + +variable default-base { + type = string + default = "ubuntu@22.04" +} + +variable default-series { + type = string + default = "jammy" +} + +variable placement-channel { + type = string + default = "yoga/stable" +} + +variable placement-revision { + type = string + default = "" +} + +variable oam-space { + type = string + default = "oam" +} + +variable admin-space { + type = string + default = "admin" +} + +variable public-space { + type = string + default = "public" +} + +variable internal-space { + type = string + default = "internal" +} + +variable ceph-public-space { + type = string + default = "ceph-public" +} + +variable ceph-cluster-space { + type = string + default = "ceph-cluster" +} + +variable overlay-space { + type = string + default = "overlay" +} + +variable openstack-origin { + type = string + default = "distro" +} + +variable openstack-region { + type = string + default = "RegionOne" +} + +variable worker-multiplier { + type = string + default = "0.25" +} + +variable app-name { + type = string + default = "placement" +} + +variable vips { + type = map(string) + default = {} +} + +variable keystone_app { + type = string + default = "keystone" +} + +variable novacc_app { + type = string + default = "nova-cloud-controller" +} + +variable placement-config-overrides { + type = map(string) + default = {} +} + +locals { + base-placement-config = { + worker-multiplier = var.worker-multiplier + openstack-origin = var.openstack-origin + vip = var.vips["placement"] + } + + placement-config = merge( + local.base-placement-config, + var.placement-config-overrides + ) +}