diff --git a/juju/home-maas-jammy/00-variables.tf b/juju/home-maas-jammy/00-variables.tf index 0ca1100..6e37e68 100644 --- a/juju/home-maas-jammy/00-variables.tf +++ b/juju/home-maas-jammy/00-variables.tf @@ -11,24 +11,27 @@ variable num_units { variable controller_ids { type = list(string) - default = ["100", "101", "102", - "103", "104", "105"] + default = [] } variable compute_ids { type = list(string) - default = ["1000", "1001", "1002", "1003", - "1004", "1005", "1006", "1007"] + default = [] +} + +variable dpdk_ids { + type = list(string) + default = [] } variable sdn_ids { type = list(string) - default = ["400", "401", "402"] + default = [] } variable k8s_ids { type = list(string) - default = ["300", "301", "302"] + default = [] } variable apt_mirror { @@ -365,3 +368,8 @@ variable expected-mon-count { type = string default = "3" } + +variable nova-default-filters { + type = string + default = "" +} diff --git a/juju/home-maas-jammy/04-keystone.tf b/juju/home-maas-jammy/04-keystone.tf deleted file mode 100644 index d9e2ff1..0000000 --- a/juju/home-maas-jammy/04-keystone.tf +++ /dev/null @@ -1,130 +0,0 @@ -resource "juju_machine" "keystone" { - 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]) - constraints = "spaces=oam" -} - -resource "juju_application" "keystone" { - name = "keystone" - - model = var.model-name - - charm { - name = "keystone" - channel = var.openstack-channel - base = var.default-base - } - - machines = [ - for res in juju_machine.keystone : - res.machine_id - ] - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.public-space - endpoint = "public" - },{ - space = var.admin-space - endpoint = "admin" - },{ - space = var.internal-space - endpoint = "internal" - },{ - space = var.internal-space - endpoint = "shared-db" - }] - - config = { - worker-multiplier = var.worker-multiplier - openstack-origin = var.openstack-origin - vip = var.vips["keystone"] - region = var.openstack-region - preferred-api-version = "3" - token-provider = "fernet" - admin-password = "openstack" - } -} - -resource "juju_application" "keystone-mysql-router" { - name = "keystone-mysql-router" - - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } -} - -resource "juju_application" "hacluster-keystone" { - name = "hacluster-keystone" - - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } -} - -resource "juju_integration" "keystone-ha" { - - model = var.model-name - - application { - name = juju_application.keystone.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-keystone.name - endpoint = "ha" - } -} - -resource "juju_integration" "keystone-mysql" { - - model = var.model-name - - application { - name = juju_application.keystone.name - endpoint = "shared-db" - } - - application { - name = juju_application.keystone-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "keystone-db" { - - model = var.model-name - - application { - name = juju_application.keystone-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } -} diff --git a/juju/home-maas-jammy/04-openstack-common.tf b/juju/home-maas-jammy/04-openstack-common.tf new file mode 100644 index 0000000..3015f54 --- /dev/null +++ b/juju/home-maas-jammy/04-openstack-common.tf @@ -0,0 +1,174 @@ +# Add all the core modules required for openstack + +module "rabbitmq-server" { + source = "./modules/rabbitmq-server" + + # Common variables + controller_ids = var.controller_ids + all_machines = juju_machine.all_machines + model-name = var.model-name +} + +module "keystone" { + source = "./modules/keystone" + + # Glance variables + keystone-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 +} + +module "glance" { + source = "./modules/glance" + + # Glance variables + glance-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 + + # Dependancies + keystone_app = module.keystone.keystone.name + ceph-mon_app = juju_application.ceph-mon.name + cinder_app = module.cinder.cinder.name + rabbitmq-server_app = module.rabbitmq-server.rabbitmq-server.name +} + +module "cinder" { + source = "./modules/cinder" + + # Cinder variables + cinder-channel = var.openstack-channel + cinder-config-overrides = { + enabled-services = "api,scheduler,volume" + } + + cinder-ceph-sub = 1 + + # 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 + + # Dependancies + keystone_app = module.keystone.keystone.name + ceph-mon_app = juju_application.ceph-mon.name + rabbitmq-server_app = module.rabbitmq-server.rabbitmq-server.name +} + +module "cinder-backup" { + source = "./modules/cinder" + + app-name = "cinder-backup" + + # Cinder variables + cinder-channel = var.openstack-channel + cinder-config-overrides = { + enabled-services = "backup" + } + + cinder-ceph-sub = 1 + + # 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 + + # Dependancies + keystone_app = module.keystone.keystone.name + ceph-mon_app = juju_application.ceph-mon.name + rabbitmq-server_app = module.rabbitmq-server.rabbitmq-server.name +} + +module "nova-compute-kvm" { + source = "./modules/nova-compute" + + app-name = "nova-compute-kvm" + + ovn-chassis-app-name = "ovn-chassis-kvm" + ovn-chassis-config = { + bridge-interface-mappings = var.data-port + ovn-bridge-mappings = var.bridge-mappings + } + + sysconfig-app-name = "sysconfig-compute-kvm" + sysconfig-config = { + governor = "performance" + enable-pti = "on" + update-grub = "true" + enable-tsx = "true" + } + + # Nova Compute variables + nova-compute-channel = var.openstack-channel + + # Common variables + compute_ids = var.compute_ids + all_machines = juju_machine.all_machines + model-name = var.model-name + + # Dependancies + ovn-central_app = juju_application.ovn-central.name + ceph-mon_app = juju_application.ceph-mon.name + glance_app = module.glance.glance.name + cinder-ceph_app = module.cinder.cinder-ceph.name + rabbitmq-server_app = module.rabbitmq-server.rabbitmq-server.name +} + +module "nova-compute-kvm-dpdk" { + source = "./modules/nova-compute" + + app-name = "nova-compute-kvm-dpdk" + + ovn-chassis-app-name = "ovn-chassis-dpdk" + ovn-chassis-config = { + bridge-interface-mappings = var.data-port + ovn-bridge-mappings = var.bridge-mappings + enable-dpdk = true + dpdk-socket-cores = 1 + dpdk-socket-memory = 512 + dpdk-driver = "vfio-pci" + dpdk-runtime-libraries = "librte-net-vhost22" + #dpdk-runtime-libraries = "librte-net-virtio22" + } + + sysconfig-app-name = "sysconfig-compute-dpdk" + sysconfig-config = { + enable-iommu = "true" + governor = "performance" + enable-pti = "on" + update-grub = "true" + enable-tsx = "true" + hugepages = 256 + hugepagesz = "2M" + #default-hugepagesz = "1G" + } + + # Nova Compute variables + nova-compute-channel = var.openstack-channel + + # Common variables + compute_ids = var.dpdk_ids + all_machines = juju_machine.all_machines + model-name = var.model-name + + # Dependancies + ovn-central_app = juju_application.ovn-central.name + ceph-mon_app = juju_application.ceph-mon.name + glance_app = module.glance.glance.name + cinder-ceph_app = module.cinder.cinder-ceph.name + rabbitmq-server_app = module.rabbitmq-server.rabbitmq-server.name +} diff --git a/juju/home-maas-jammy/05-ceph.tf b/juju/home-maas-jammy/05-ceph.tf index d282fca..5f85a02 100644 --- a/juju/home-maas-jammy/05-ceph.tf +++ b/juju/home-maas-jammy/05-ceph.tf @@ -126,17 +126,14 @@ resource "juju_application" "ceph-radosgw" { } } -resource "juju_application" "hacluster-radosgw" { - name = "hacluster-radosgw" +module "radosgw-hacluster" { + source = "./modules/hacluster" - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } + sub-name = juju_application.ceph-radosgw.name + model-name = juju_model.openstack.name } + resource "juju_integration" "osd-mon" { model = var.model-name @@ -167,21 +164,6 @@ resource "juju_integration" "rgw-mon" { } } -resource "juju_integration" "rgw-ha" { - - model = var.model-name - - application { - name = juju_application.ceph-radosgw.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-radosgw.name - endpoint = "ha" - } -} - resource "juju_integration" "rgw-keystone" { model = var.model-name @@ -192,7 +174,7 @@ resource "juju_integration" "rgw-keystone" { } application { - name = juju_application.keystone.name + name = module.keystone.keystone.name endpoint = "identity-service" } } diff --git a/juju/home-maas-jammy/05-cinder-backup.tf b/juju/home-maas-jammy/05-cinder-backup.tf deleted file mode 100644 index e2c9841..0000000 --- a/juju/home-maas-jammy/05-cinder-backup.tf +++ /dev/null @@ -1,164 +0,0 @@ -resource "juju_machine" "cinder-backup" { - 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]) - constraints = "spaces=oam" -} - -resource "juju_application" "cinder-backup" { - name = "cinder-backup" - - model = var.model-name - - charm { - name = "cinder" - channel = var.openstack-channel - base = var.default-base - } - - machines = [ - for res in juju_machine.cinder-backup : - res.machine_id - ] - - endpoint_bindings = [{ - space = var.oam-space - },{ - endpoint = "public" - space = var.public-space - },{ - endpoint = "admin" - space = var.admin-space - },{ - endpoint = "internal" - space = var.internal-space - },{ - endpoint = "shared-db" - space = var.internal-space - }] - - config = { - worker-multiplier = var.worker-multiplier - openstack-origin = var.openstack-origin - region = var.openstack-region - use-internal-endpoints = "true" - block-device = "None" - glance-api-version = "2" - enabled-services = "backup" - } -} - -resource "juju_application" "cinder-backup-mysql-router" { - name = "cinder-backup-mysql-router" - - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } -} - -resource "juju_integration" "cinder-backup-mysql" { - - model = var.model-name - - application { - name = juju_application.cinder-backup.name - endpoint = "shared-db" - } - - application { - name = juju_application.cinder-backup-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "cinder-backup-db" { - - model = var.model-name - - application { - name = juju_application.cinder-backup-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } -} - -resource "juju_integration" "cinder-backup-rmq" { - - model = var.model-name - - application { - name = juju_application.cinder-backup.name - endpoint = "amqp" - } - - application { - name = juju_application.rabbitmq-server.name - endpoint = "amqp" - } -} - -resource "juju_integration" "cinder-backup-keystone" { - - model = var.model-name - - application { - name = juju_application.cinder-backup.name - endpoint = "identity-service" - } - - application { - name = juju_application.keystone.name - endpoint = "identity-service" - } -} - -resource "juju_integration" "cinder-backup-ceph" { - - model = var.model-name - - application { - name = juju_application.cinder-backup.name - endpoint = "ceph" - } - - application { - name = juju_application.ceph-mon.name - endpoint = "client" - } -} - -resource "juju_integration" "cinder-ceph-cinder-backup" { - - model = var.model-name - - application { - name = juju_application.cinder-ceph.name - endpoint = "storage-backend" - } - - application { - name = juju_application.cinder-backup.name - endpoint = "storage-backend" - } -} diff --git a/juju/home-maas-jammy/05-cinder.tf b/juju/home-maas-jammy/05-cinder.tf deleted file mode 100644 index f80671c..0000000 --- a/juju/home-maas-jammy/05-cinder.tf +++ /dev/null @@ -1,222 +0,0 @@ -resource "juju_machine" "cinder" { - count = var.num_units - model = var.model-name - placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids[count.index]].machine_id]) - constraints = "spaces=oam" -} - -resource "juju_application" "cinder" { - name = "cinder" - - model = var.model-name - - charm { - name = "cinder" - channel = var.openstack-channel - base = var.default-base - } - - machines = [ - for res in juju_machine.cinder : - res.machine_id - ] - - endpoint_bindings = [{ - space = var.oam-space - },{ - endpoint = "public" - space = var.public-space - },{ - endpoint = "admin" - space = var.admin-space - },{ - endpoint = "internal" - space = var.internal-space - },{ - endpoint = "shared-db" - space = var.internal-space - }] - - config = { - worker-multiplier = var.worker-multiplier - openstack-origin = var.openstack-origin - region = var.openstack-region - vip = var.vips["cinder"] - use-internal-endpoints = "true" - block-device = "None" - glance-api-version = "2" - enabled-services = "api,scheduler,volume" - } -} - -resource "juju_application" "cinder-ceph" { - name = "cinder-ceph" - - model = var.model-name - - charm { - name = "cinder-ceph" - channel = var.openstack-channel - } - - config = { - restrict-ceph-pools = "false" - } -} - - -resource "juju_application" "cinder-mysql-router" { - name = "cinder-mysql-router" - - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } -} - -resource "juju_application" "hacluster-cinder" { - name = "hacluster-cinder" - - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } -} - -resource "juju_integration" "cinder-ha" { - - model = var.model-name - - application { - name = juju_application.cinder.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-cinder.name - endpoint = "ha" - } -} - -resource "juju_integration" "cinder-mysql" { - - model = var.model-name - - application { - name = juju_application.cinder.name - endpoint = "shared-db" - } - - application { - name = juju_application.cinder-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "cinder-db" { - - model = var.model-name - - application { - name = juju_application.cinder-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } -} - -resource "juju_integration" "cinder-rmq" { - - model = var.model-name - - application { - name = juju_application.cinder.name - endpoint = "amqp" - } - - application { - name = juju_application.rabbitmq-server.name - endpoint = "amqp" - } -} - -resource "juju_integration" "cinder-keystone" { - - model = var.model-name - - application { - name = juju_application.cinder.name - endpoint = "identity-service" - } - - application { - name = juju_application.keystone.name - endpoint = "identity-service" - } -} - -resource "juju_integration" "cinder-ceph" { - - model = var.model-name - - application { - name = juju_application.cinder.name - endpoint = "ceph" - } - - application { - name = juju_application.ceph-mon.name - endpoint = "client" - } -} - -resource "juju_integration" "cinder-ceph-mon" { - - model = var.model-name - - application { - name = juju_application.cinder-ceph.name - endpoint = "ceph" - } - - application { - name = juju_application.ceph-mon.name - endpoint = "client" - } -} - -resource "juju_integration" "cinder-ceph-cinder" { - - model = var.model-name - - application { - name = juju_application.cinder-ceph.name - endpoint = "storage-backend" - } - - application { - name = juju_application.cinder.name - endpoint = "storage-backend" - } -} diff --git a/juju/home-maas-jammy/05-glance.tf b/juju/home-maas-jammy/05-glance.tf deleted file mode 100644 index 5b3719d..0000000 --- a/juju/home-maas-jammy/05-glance.tf +++ /dev/null @@ -1,205 +0,0 @@ -resource "juju_machine" "glance" { - count = var.num_units - model = var.model-name - placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids[count.index]].machine_id]) - constraints = "cores=2 mem=2048M spaces=oam virt-type=virtual-machine" -} - -resource "juju_application" "glance" { - name = "glance" - - model = var.model-name - - charm { - name = "glance" - channel = var.openstack-channel - base = var.default-base - } - - machines = [ - for res in juju_machine.glance : - res.machine_id - ] - - endpoint_bindings = [{ - space = var.oam-space - },{ - endpoint = "public" - space = var.public-space - },{ - endpoint = "admin" - space = var.admin-space - },{ - endpoint = "internal" - space = var.internal-space - },{ - endpoint = "shared-db" - space = var.internal-space - }] - - config = { - worker-multiplier = var.worker-multiplier - openstack-origin = var.openstack-origin - region = var.openstack-region - vip = var.vips["glance"] - use-internal-endpoints = "true" - restrict-ceph-pools = "false" - } -} - -resource "juju_application" "glance-mysql-router" { - name = "glance-mysql-router" - - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } -} - -resource "juju_application" "hacluster-glance" { - name = "hacluster-glance" - - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } -} - -resource "juju_integration" "glance-ha" { - - - model = var.model-name - - application { - name = juju_application.glance.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-glance.name - endpoint = "ha" - } -} - -resource "juju_integration" "glance-mysql" { - - model = var.model-name - - application { - name = juju_application.glance.name - endpoint = "shared-db" - } - - application { - name = juju_application.glance-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "glance-db" { - - model = var.model-name - - application { - name = juju_application.glance-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } -} - -resource "juju_integration" "glance-rmq" { - - model = var.model-name - - application { - name = juju_application.glance.name - endpoint = "amqp" - } - - application { - name = juju_application.rabbitmq-server.name - endpoint = "amqp" - } -} - -resource "juju_integration" "glance-keystone" { - - model = var.model-name - - application { - name = juju_application.glance.name - endpoint = "identity-service" - } - - application { - name = juju_application.keystone.name - endpoint = "identity-service" - } -} - -resource "juju_integration" "glance-ceph" { - - model = var.model-name - - application { - name = juju_application.glance.name - endpoint = "ceph" - } - - application { - name = juju_application.ceph-mon.name - endpoint = "client" - } -} - -#resource "juju_integration" "glance-cinder" { -# -# model = var.model-name -# -# application { -# name = juju_application.glance.name -# endpoint = "image-service" -# } -# -# application { -# name = juju_application.cinder.name -# endpoint = "image-service" -# } -#} - -resource "juju_integration" "glance-cinder-image" { - - model = var.model-name - - application { - name = juju_application.glance.name - endpoint = "cinder-volume-service" - } - - application { - name = juju_application.cinder.name - endpoint = "cinder-volume-service" - } -} diff --git a/juju/home-maas-jammy/05-heat.tf b/juju/home-maas-jammy/05-heat.tf index 79eecad..ade9e81 100644 --- a/juju/home-maas-jammy/05-heat.tf +++ b/juju/home-maas-jammy/05-heat.tf @@ -47,85 +47,18 @@ resource "juju_application" "heat" { } } -resource "juju_application" "heat-mysql-router" { - name = "heat-mysql-router" +module "heat-mysql-router" { + source = "./modules/mysql-router" - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } + sub-name = "heat" + model-name = var.model-name } -resource "juju_application" "hacluster-heat" { - name = "hacluster-heat" +module "heat-hacluster" { + source = "./modules/hacluster" - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } -} - -resource "juju_integration" "heat-ha" { - - model = var.model-name - - application { - name = juju_application.heat.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-heat.name - endpoint = "ha" - } -} - -resource "juju_integration" "heat-mysql" { - - model = var.model-name - - application { - name = juju_application.heat.name - endpoint = "shared-db" - } - - application { - name = juju_application.heat-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "heat-db" { - - model = var.model-name - - application { - name = juju_application.heat-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } + sub-name = "heat" + model-name = var.model-name } resource "juju_integration" "heat-rmq" { @@ -138,7 +71,7 @@ resource "juju_integration" "heat-rmq" { } application { - name = juju_application.rabbitmq-server.name + name = module.rabbitmq-server.rabbitmq-server.name endpoint = "amqp" } } @@ -153,7 +86,7 @@ resource "juju_integration" "heat-keystone" { } application { - name = juju_application.keystone.name + name = module.keystone.keystone.name endpoint = "identity-service" } } diff --git a/juju/home-maas-jammy/05-nova.tf b/juju/home-maas-jammy/05-nova.tf index e777bac..10e33c1 100644 --- a/juju/home-maas-jammy/05-nova.tf +++ b/juju/home-maas-jammy/05-nova.tf @@ -52,88 +52,22 @@ resource "juju_application" "nova-cloud-controller" { ram-allocation-ratio = var.ram-allocation-ratio cpu-allocation-ratio = var.cpu-allocation-ratio config-flags = "scheduler_max_attempts=20" + scheduler-default-filters = var.nova-default-filters } } -resource "juju_application" "nova-cloud-controller-mysql-router" { - name = "nova-cloud-controller-mysql-router" +module "nova-mysql-router" { + source = "./modules/mysql-router" - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } + sub-name = juju_application.nova-cloud-controller.name + model-name = juju_model.openstack.name } -resource "juju_application" "hacluster-nova" { - name = "hacluster-nova" +module "nova-hacluster" { + source = "./modules/hacluster" - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } -} - -resource "juju_integration" "nova-cloud-controller-ha" { - - model = var.model-name - - application { - name = juju_application.nova-cloud-controller.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-nova.name - endpoint = "ha" - } -} - -resource "juju_integration" "nova-cloud-controller-mysql" { - - model = var.model-name - - application { - name = juju_application.nova-cloud-controller.name - endpoint = "shared-db" - } - - application { - name = juju_application.nova-cloud-controller-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "nova-cloud-controller-db" { - - model = var.model-name - - application { - name = juju_application.nova-cloud-controller-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } + sub-name = juju_application.nova-cloud-controller.name + model-name = juju_model.openstack.name } resource "juju_integration" "nova-cloud-controller-rmq" { @@ -146,7 +80,7 @@ resource "juju_integration" "nova-cloud-controller-rmq" { } application { - name = juju_application.rabbitmq-server.name + name = module.rabbitmq-server.rabbitmq-server.name endpoint = "amqp" } } @@ -161,7 +95,7 @@ resource "juju_integration" "nova-cloud-controller-keystone" { } application { - name = juju_application.keystone.name + name = module.keystone.keystone.name endpoint = "identity-service" } } @@ -191,7 +125,7 @@ resource "juju_integration" "nova-cloud-controller-nova-compute" { } application { - name = juju_application.nova-compute-kvm.name + name = module.nova-compute-kvm.nova-compute.name endpoint = "cloud-compute" } } @@ -205,7 +139,7 @@ resource "juju_integration" "nova-cloud-controller-glance" { } application { - name = juju_application.glance.name + name = module.glance.glance.name endpoint = "image-service" } } diff --git a/juju/home-maas-jammy/05-placement.tf b/juju/home-maas-jammy/05-placement.tf index 2a70167..998f5aa 100644 --- a/juju/home-maas-jammy/05-placement.tf +++ b/juju/home-maas-jammy/05-placement.tf @@ -48,85 +48,18 @@ resource "juju_application" "placement" { } } -resource "juju_application" "placement-mysql-router" { - name = "placement-mysql-router" +module "placement-mysql-router" { + source = "./modules/mysql-router" - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } + sub-name = juju_application.placement.name + model-name = juju_model.openstack.name } -resource "juju_application" "hacluster-placement" { - name = "hacluster-placement" +module "placement-hacluster" { + source = "./modules/hacluster" - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } -} - -resource "juju_integration" "placement-ha" { - - model = var.model-name - - application { - name = juju_application.placement.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-placement.name - endpoint = "ha" - } -} - -resource "juju_integration" "placement-mysql" { - - model = var.model-name - - application { - name = juju_application.placement.name - endpoint = "shared-db" - } - - application { - name = juju_application.placement-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "placement-db" { - - model = var.model-name - - application { - name = juju_application.placement-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } + sub-name = juju_application.placement.name + model-name = juju_model.openstack.name } resource "juju_integration" "placement-keystone" { @@ -139,7 +72,7 @@ resource "juju_integration" "placement-keystone" { } application { - name = juju_application.keystone.name + name = module.keystone.keystone.name endpoint = "identity-service" } } diff --git a/juju/home-maas-jammy/06-nova-compute.tf b/juju/home-maas-jammy/06-nova-compute.tf deleted file mode 100644 index 3c11b72..0000000 --- a/juju/home-maas-jammy/06-nova-compute.tf +++ /dev/null @@ -1,184 +0,0 @@ -resource "juju_application" "nova-compute-kvm" { - name = "nova-compute-kvm" - - model = var.model-name - - charm { - name = "nova-compute" - channel = var.openstack-channel - base = var.default-base - } - - machines = [ - for index in var.compute_ids : - juju_machine.all_machines[index].machine_id - ] - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "internal" - }] - - config = { - openstack-origin = var.openstack-origin - enable-live-migration = "true" - enable-resize = "true" - migration-auth-type = "ssh" - use-internal-endpoints = "true" - libvirt-image-backend = "rbd" - restrict-ceph-pools = "false" - aa-profile-mode = "complain" - virt-type = "kvm" - customize-failure-domain = var.customize-failure-domain - reserved-host-memory = var.reserved-host-memory - cpu-allocation-ratio = var.cpu-allocation-ratio - ram-allocation-ratio = var.ram-allocation-ratio - } -} - -resource "juju_application" "ovn-chassis" { - name = "ovn-chassis" - - model = var.model-name - - charm { - name = "ovn-chassis" - channel = var.ovn-channel - } - - endpoint_bindings = [{ - space = var.oam-space - }] - - config = { - bridge-interface-mappings = var.data-port - ovn-bridge-mappings = var.bridge-mappings - } -} - -resource "juju_application" "sysconfig-compute" { - name = "sysconfig-compute" - - model = var.model-name - - charm { - name = "sysconfig" - channel = var.sysconfig_channel - revision = var.sysconfig_revision - } - - config = { -# enable-iommu = "false" - governor = "performance" - enable-pti = "on" - update-grub = "true" - enable-tsx = "true" - } -} - -resource "juju_integration" "compute-ovn" { - - model = var.model-name - - application { - name = juju_application.ovn-chassis.name - endpoint = "nova-compute" - } - - application { - name = juju_application.nova-compute-kvm.name - endpoint = "neutron-plugin" - } -} - -resource "juju_integration" "compute-sysconfig" { - - model = var.model-name - - application { - name = juju_application.nova-compute-kvm.name - endpoint = "juju-info" - } - - application { - name = juju_application.sysconfig-compute.name - endpoint = "juju-info" - } -} - -resource "juju_integration" "compute-ceph-mon" { - - model = var.model-name - - application { - name = juju_application.nova-compute-kvm.name - endpoint = "ceph" - } - - application { - name = juju_application.ceph-mon.name - endpoint = "client" - } -} - -resource "juju_integration" "chassis-central" { - - model = var.model-name - - application { - name = juju_application.ovn-chassis.name - endpoint = "ovsdb" - } - - application { - name = juju_application.ovn-central.name - endpoint = "ovsdb" - } -} - -resource "juju_integration" "nova-compute-rmq" { - - model = var.model-name - - application { - name = juju_application.nova-compute-kvm.name - endpoint = "amqp" - } - - application { - name = juju_application.rabbitmq-server.name - endpoint = "amqp" - } -} - -resource "juju_integration" "nova-compute-glance" { - - model = var.model-name - - application { - name = juju_application.nova-compute-kvm.name - endpoint = "image-service" - } - - application { - name = juju_application.glance.name - endpoint = "image-service" - } -} - -resource "juju_integration" "nova-compute-cinder-ceph" { - - model = var.model-name - - application { - name = juju_application.nova-compute-kvm.name - endpoint = "ceph-access" - } - - application { - name = juju_application.cinder-ceph.name - endpoint = "ceph-access" - } -} diff --git a/juju/home-maas-jammy/06-openstack-dashboard.tf b/juju/home-maas-jammy/06-openstack-dashboard.tf index d86b6f1..ce4d314 100644 --- a/juju/home-maas-jammy/06-openstack-dashboard.tf +++ b/juju/home-maas-jammy/06-openstack-dashboard.tf @@ -43,85 +43,18 @@ resource "juju_application" "openstack-dashboard" { } } -resource "juju_application" "openstack-dashboard-mysql-router" { - name = "openstack-dashboard-mysql-router" +module "openstack-dashboard-mysql-router" { + source = "./modules/mysql-router" - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } + sub-name = juju_application.openstack-dashboard.name + model-name = juju_model.openstack.name } -resource "juju_application" "hacluster-openstack-dashboard" { - name = "hacluster-openstack-dashboard" +module "openstack-dashboard-hacluster" { + source = "./modules/hacluster" - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } -} - -resource "juju_integration" "openstack-dashboard-ha" { - - model = var.model-name - - application { - name = juju_application.openstack-dashboard.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-openstack-dashboard.name - endpoint = "ha" - } -} - -resource "juju_integration" "openstack-dashboard-mysql" { - - model = var.model-name - - application { - name = juju_application.openstack-dashboard.name - endpoint = "shared-db" - } - - application { - name = juju_application.openstack-dashboard-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "openstack-dashboard-db" { - - model = var.model-name - - application { - name = juju_application.openstack-dashboard-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } + sub-name = juju_application.openstack-dashboard.name + model-name = juju_model.openstack.name } resource "juju_integration" "openstack-dashboard-keystone" { @@ -134,7 +67,7 @@ resource "juju_integration" "openstack-dashboard-keystone" { } application { - name = juju_application.keystone.name + name = module.keystone.keystone.name endpoint = "identity-service" } } diff --git a/juju/home-maas-jammy/08-neutron.tf b/juju/home-maas-jammy/08-neutron.tf index 416d449..f5aeda6 100644 --- a/juju/home-maas-jammy/08-neutron.tf +++ b/juju/home-maas-jammy/08-neutron.tf @@ -98,87 +98,20 @@ resource "juju_application" "neutron-api-plugin-ovn" { }] } +module "neutron-mysql-router" { + source = "./modules/mysql-router" -resource "juju_application" "neutron-mysql-router" { - name = "neutron-mysql-router" - - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } + sub-name = juju_application.neutron-api.name + model-name = juju_model.openstack.name } -resource "juju_application" "hacluster-neutron" { - name = "hacluster-neutron" +module "neutron-hacluster" { + source = "./modules/hacluster" - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } + sub-name = juju_application.neutron-api.name + model-name = juju_model.openstack.name } -resource "juju_integration" "neutron-ha" { - - model = var.model-name - - application { - name = juju_application.neutron-api.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-neutron.name - endpoint = "ha" - } -} - -resource "juju_integration" "neutron-mysql" { - - model = var.model-name - - application { - name = juju_application.neutron-api.name - endpoint = "shared-db" - } - - application { - name = juju_application.neutron-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "neutron-db" { - - model = var.model-name - - application { - name = juju_application.neutron-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } -} resource "juju_integration" "neutron-keystone" { @@ -190,7 +123,7 @@ resource "juju_integration" "neutron-keystone" { } application { - name = juju_application.keystone.name + name = module.keystone.keystone.name endpoint = "identity-service" } } @@ -205,7 +138,7 @@ resource "juju_integration" "neutron-api-rmq" { } application { - name = juju_application.rabbitmq-server.name + name = module.rabbitmq-server.rabbitmq-server.name endpoint = "amqp" } } @@ -239,4 +172,3 @@ resource "juju_integration" "neutron-api-plugin-ovn-central" { endpoint = "ovsdb-cms" } } - diff --git a/juju/home-maas-jammy/10-vault.tf b/juju/home-maas-jammy/10-vault.tf index af8e555..167c28e 100644 --- a/juju/home-maas-jammy/10-vault.tf +++ b/juju/home-maas-jammy/10-vault.tf @@ -30,45 +30,20 @@ resource "juju_application" "vault" { } -resource "juju_application" "vault-mysql-router" { - name = "vault-mysql-router" +module "vault-mysql-router" { + source = "./modules/mysql-router" - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [ - { - space = var.oam-space - },{ - endpoint = "shared-db" - space = var.internal-space - },{ - endpoint = "db-router" - space = var.internal-space - }, - ] - - config = { - source = var.openstack-origin - } + sub-name = juju_application.vault.name + model-name = juju_model.openstack.name } -resource "juju_application" "hacluster-vault" { - name = "hacluster-vault" +module "vault-hacluster" { + source = "./modules/hacluster" - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } + sub-name = juju_application.vault.name + model-name = juju_model.openstack.name } - resource "juju_machine" "etcd" { count = var.num_units model = var.model-name @@ -160,36 +135,6 @@ resource "juju_integration" "etcd-easyrsa" { } } -resource "juju_integration" "vault-ha" { - - model = var.model-name - - application { - name = juju_application.vault.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-vault.name - endpoint = "ha" - } -} - -resource "juju_integration" "vault-mysql" { - - model = var.model-name - - application { - name = juju_application.vault.name - endpoint = "shared-db" - } - - application { - name = juju_application.vault-mysql-router.name - endpoint = "shared-db" - } -} - resource "juju_integration" "vault-ceph" { model = var.model-name @@ -205,21 +150,6 @@ resource "juju_integration" "vault-ceph" { } } -resource "juju_integration" "vault-db" { - - model = var.model-name - - application { - name = juju_application.vault-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } -} - locals { cert_apps = [ "ceph-radosgw", @@ -234,6 +164,7 @@ locals { "openstack-dashboard", "ovn-central", "ovn-chassis", + "ovn-chassis-dpdk", "placement", ] diff --git a/juju/home-maas-jammy/additional/05-cinder-lvm.tf b/juju/home-maas-jammy/additional/05-cinder-lvm.tf index b715e14..0d870ab 100644 --- a/juju/home-maas-jammy/additional/05-cinder-lvm.tf +++ b/juju/home-maas-jammy/additional/05-cinder-lvm.tf @@ -52,32 +52,6 @@ resource "juju_application" "cinder-volume" { } } -resource "juju_application" "cinder-vol-mysql-router" { - name = "cinder-vol-mysql-router" - - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } -} - - resource "juju_application" "cinder-lvm" { name = "cinder-lvm" @@ -111,34 +85,18 @@ resource "juju_integration" "cinder-lvm-vol" { } } -resource "juju_integration" "cinder-vol-mysql" { +module "cinder-volume-mysql-router" { + source = "./modules/mysql-router" - model = var.model-name - - application { - name = juju_application.cinder-volume.name - endpoint = "shared-db" - } - - application { - name = juju_application.cinder-vol-mysql-router.name - endpoint = "shared-db" - } + app-name = juju_application.cinder-volume.name + model-name = juju_model.openstack.name } -resource "juju_integration" "cinder-vol-db" { +module "cinder-volume-hacluster" { + source = "./modules/hacluster" - model = var.model-name - - application { - name = juju_application.cinder-vol-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } + app-name = juju_application.cinder-volume.name + model-name = juju_model.openstack.name } resource "juju_integration" "cinder-vol-rmq" { diff --git a/juju/home-maas-jammy/additional/05-gnocchi.tf b/juju/home-maas-jammy/additional/05-gnocchi.tf index 1132378..52b25ef 100644 --- a/juju/home-maas-jammy/additional/05-gnocchi.tf +++ b/juju/home-maas-jammy/additional/05-gnocchi.tf @@ -53,90 +53,18 @@ resource "juju_application" "gnocchi" { } } -resource "juju_application" "gnocchi-mysql-router" { - name = "gnocchi-mysql-router" +module "gnocchi-mysql-router" { + source = "./modules/mysql-router" - model = var.model-name - - charm { - name = "mysql-router" - channel = var.mysql-router-channel - } - - units = 0 - - endpoint_bindings = [{ - space = var.oam-space - },{ - space = var.internal-space - endpoint = "shared-db" - },{ - space = var.internal-space - endpoint = "db-router" - }] - - config = { - source = var.openstack-origin - } + app-name = juju_application.gnocchi.name + model-name = juju_model.openstack.name } -resource "juju_application" "hacluster-gnocchi" { - name = "hacluster-gnocchi" +module "gnocchi-hacluster" { + source = "./modules/hacluster" - model = var.model-name - - charm { - name = "hacluster" - channel = var.hacluster-channel - } - - units = 0 -} - -resource "juju_integration" "gnocchi-ha" { - - - model = var.model-name - - application { - name = juju_application.gnocchi.name - endpoint = "ha" - } - - application { - name = juju_application.hacluster-gnocchi.name - endpoint = "ha" - } -} - -resource "juju_integration" "gnocchi-mysql" { - - model = var.model-name - - application { - name = juju_application.gnocchi.name - endpoint = "shared-db" - } - - application { - name = juju_application.gnocchi-mysql-router.name - endpoint = "shared-db" - } -} - -resource "juju_integration" "gnocchi-db" { - - model = var.model-name - - application { - name = juju_application.gnocchi-mysql-router.name - endpoint = "db-router" - } - - application { - name = juju_application.mysql-innodb-cluster.name - endpoint = "db-router" - } + app-name = juju_application.gnocchi.name + model-name = juju_model.openstack.name } resource "juju_integration" "gnocchi-rmq" { diff --git a/juju/home-maas-jammy/additional/09-filebeat.tf b/juju/home-maas-jammy/additional/09-filebeat.tf index a2e0de6..0ff1075 100644 --- a/juju/home-maas-jammy/additional/09-filebeat.tf +++ b/juju/home-maas-jammy/additional/09-filebeat.tf @@ -54,7 +54,7 @@ resource "juju_application" "filebeat" { } resource "juju_integration" "filebeat-integration" { - for_each = toset(var.all_services) + for_each = toset(var.filebeat_services) model = var.model-name diff --git a/juju/home-maas-jammy/microk8s/32-microk8s.tf b/juju/home-maas-jammy/microk8s/32-microk8s.tf index f71ff00..ac48311 100644 --- a/juju/home-maas-jammy/microk8s/32-microk8s.tf +++ b/juju/home-maas-jammy/microk8s/32-microk8s.tf @@ -14,8 +14,11 @@ resource "juju_application" "microk8s" { res.machine_id ] + endpoint_bindings = [{ + space = var.oam-space + }] - endpoint_bindings = [{ - space = var.oam-space - }] + config = { + hostpath_storage = true + } } diff --git a/juju/home-maas-jammy/modules/cinder-ceph/init.tf b/juju/home-maas-jammy/modules/cinder-ceph/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder-ceph/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/modules/cinder-ceph/main.tf b/juju/home-maas-jammy/modules/cinder-ceph/main.tf new file mode 100644 index 0000000..bfd2909 --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder-ceph/main.tf @@ -0,0 +1,30 @@ +resource "juju_application" "cinder-ceph" { + name = var.ceph-pool=="" ? var.app-name : "${var.app-name}-${var.ceph-pool}" + + model = var.model-name + + charm { + name = "cinder-ceph" + channel = var.cinder-ceph-channel + } + + config = { + restrict-ceph-pools = "false" + } +} + +resource "juju_integration" "cinder-ceph-mon" { + + model = var.model-name + + application { + name = juju_application.cinder-ceph.name + endpoint = "ceph" + } + + application { + name = var.ceph-mon_app + endpoint = "client" + } +} + diff --git a/juju/home-maas-jammy/modules/cinder-ceph/outputs.tf b/juju/home-maas-jammy/modules/cinder-ceph/outputs.tf new file mode 100644 index 0000000..9cb177c --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder-ceph/outputs.tf @@ -0,0 +1,3 @@ +output "cinder-ceph" { + value = juju_application.cinder-ceph +} diff --git a/juju/home-maas-jammy/modules/cinder-ceph/variables.tf b/juju/home-maas-jammy/modules/cinder-ceph/variables.tf new file mode 100644 index 0000000..76c7844 --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder-ceph/variables.tf @@ -0,0 +1,109 @@ +variable model-name { + type = string + default = "openstack" +} + +variable default-base { + type = string + default = "ubuntu@22.04" +} + +variable default-series { + type = string + default = "jammy" +} + +variable cinder-ceph-channel { + type = string + default = "yoga/stable" +} + +variable cinder-ceph-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 = "cinder-ceph" +} + +variable vips { + type = map(string) + default = {} +} + +variable ceph-pool { + type = string + default = "" +} + +variable ceph-mon_app { + type = string + default = "ceph-mon" +} + +variable cinder-ceph-config-overrides { + type = map(string) + default = {} +} + +locals { + base-cinder-ceph-config = { + } + + cinder-ceph-config = merge( + local.base-cinder-ceph-config, + var.cinder-ceph-config-overrides + ) +} diff --git a/juju/home-maas-jammy/modules/cinder-lvm/init.tf b/juju/home-maas-jammy/modules/cinder-lvm/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder-lvm/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/modules/cinder-lvm/variables.tf b/juju/home-maas-jammy/modules/cinder-lvm/variables.tf new file mode 100644 index 0000000..c2b5453 --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder-lvm/variables.tf @@ -0,0 +1,116 @@ +variable num_units { + type = number + default = 3 +} + +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 keystone-channel { + type = string + default = "yoga/stable" +} + +variable keystone-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 = "keystone" +} + +variable vips { + type = map(string) + default = {} +} + +variable keystone-config-overrides { + type = map(string) + default = {} +} + +locals { + base-keystone-config = { + worker-multiplier = var.worker-multiplier + openstack-origin = var.openstack-origin + region = var.openstack-region + vip = var.vips["keystone"] + preferred-api-version = "3" + token-provider = "fernet" + admin-password = "openstack" + } + + keystone-config = merge( + local.base-keystone-config, + var.keystone-config-overrides + ) +} diff --git a/juju/home-maas-jammy/modules/cinder/init.tf b/juju/home-maas-jammy/modules/cinder/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder/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/modules/cinder/main.tf b/juju/home-maas-jammy/modules/cinder/main.tf new file mode 100644 index 0000000..99015ef --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder/main.tf @@ -0,0 +1,130 @@ +resource "juju_machine" "cinder" { + count = var.num_units + model = var.model-name + placement = join(":", ["lxd", var.all_machines[var.controller_ids[count.index]].machine_id]) + constraints = "spaces=oam" +} + +resource "juju_application" "cinder" { + name = var.app-name + + model = var.model-name + + charm { + name = "cinder" + channel = var.cinder-channel + base = var.default-base + } + + machines = [ + for res in juju_machine.cinder : + res.machine_id + ] + + endpoint_bindings = [{ + space = var.oam-space + },{ + endpoint = "public" + space = var.public-space + },{ + endpoint = "admin" + space = var.admin-space + },{ + endpoint = "internal" + space = var.internal-space + },{ + endpoint = "shared-db" + space = var.internal-space + }] + + config = local.cinder-config +} + +module "cinder-mysql-router" { + source = "../mysql-router" + + sub-name = var.app-name + model-name = var.model-name +} + +module "cinder-hacluster" { + source = "../hacluster" + + sub-name = var.app-name + model-name = var.model-name +} + +module "cinder-ceph" { + count = var.cinder-ceph-sub > 0 ? 1 : 0 + source = "../cinder-ceph" + + model-name = var.model-name +} + +module "cinder-lvm" { + count = var.cinder-lvm-sub > 0 ? 1 : 0 + source = "../cinder-lvm" + + model-name = var.model-name +} + +resource "juju_integration" "cinder-rmq" { + + model = var.model-name + + application { + name = juju_application.cinder.name + endpoint = "amqp" + } + + application { + name = var.rabbitmq-server_app + endpoint = "amqp" + } +} + +resource "juju_integration" "cinder-keystone" { + + model = var.model-name + + application { + name = juju_application.cinder.name + endpoint = "identity-service" + } + + application { + name = var.keystone_app + endpoint = "identity-service" + } +} + +resource "juju_integration" "cinder-ceph" { + + model = var.model-name + + application { + name = juju_application.cinder.name + endpoint = "ceph" + } + + application { + name = var.ceph-mon_app + endpoint = "client" + } +} + +resource "juju_integration" "cinder-ceph-cinder" { + count = var.cinder-ceph-sub > 0 ? 1 : 0 + + model = var.model-name + + application { + name = module.cinder-ceph[0].cinder-ceph.name + endpoint = "storage-backend" + } + + application { + name = juju_application.cinder.name + endpoint = "storage-backend" + } +} diff --git a/juju/home-maas-jammy/modules/cinder/outputs.tf b/juju/home-maas-jammy/modules/cinder/outputs.tf new file mode 100644 index 0000000..b3e053b --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder/outputs.tf @@ -0,0 +1,11 @@ +output "cinder" { + value = juju_application.cinder +} + +output "cinder-ceph" { + value = var.cinder-ceph-sub > 0 ? module.cinder-ceph[0].cinder-ceph : null +} + +output "cinder-lvm" { + value = var.cinder-lvm-sub > 0 ? module.cinder-lvm[0].cinder-lvm : null +} diff --git a/juju/home-maas-jammy/modules/cinder/variables.tf b/juju/home-maas-jammy/modules/cinder/variables.tf new file mode 100644 index 0000000..8fc3fa1 --- /dev/null +++ b/juju/home-maas-jammy/modules/cinder/variables.tf @@ -0,0 +1,152 @@ +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 cinder-channel { + type = string + default = "yoga/stable" +} + +variable cinder-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 = "cinder" +} + +variable vips { + type = map(string) + default = {} +} + +variable keystone_app { + type = string + default = "keystone" +} +variable ceph-mon_app { + type = string + default = "ceph-mon" +} +variable rabbitmq-server_app { + type = string + default = "rabbitmq-server" +} + +variable cinder-ceph-sub { + type = number + default = 0 +} + +variable cinder-lvm-sub { + type = number + default = 0 +} + +variable cinder-config-overrides { + type = map(string) + default = {} +} + +locals { + base-cinder-config = { + worker-multiplier = var.worker-multiplier + openstack-origin = var.openstack-origin + region = var.openstack-region + vip = var.vips["cinder"] + use-internal-endpoints = "true" + block-device = "None" + glance-api-version = "2" + } + + cinder-config = merge( + local.base-cinder-config, + var.cinder-config-overrides + ) +} diff --git a/juju/home-maas-jammy/modules/glance/init.tf b/juju/home-maas-jammy/modules/glance/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/glance/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/modules/glance/main.tf b/juju/home-maas-jammy/modules/glance/main.tf new file mode 100644 index 0000000..7c96d34 --- /dev/null +++ b/juju/home-maas-jammy/modules/glance/main.tf @@ -0,0 +1,180 @@ +resource "juju_machine" "glance" { + count = var.num_units + model = var.model-name + placement = join(":", ["lxd", var.all_machines[var.controller_ids[count.index]].machine_id]) + constraints = "cores=2 mem=2048M spaces=oam virt-type=virtual-machine" +} + +resource "juju_application" "glance" { + name = var.app-name + + model = var.model-name + + charm { + name = "glance" + channel = var.glance-channel + base = var.default-base + } + + machines = [ + for res in juju_machine.glance : + res.machine_id + ] + + endpoint_bindings = [{ + space = var.oam-space + },{ + endpoint = "public" + space = var.public-space + },{ + endpoint = "admin" + space = var.admin-space + },{ + endpoint = "internal" + space = var.internal-space + },{ + endpoint = "shared-db" + space = var.internal-space + }] + + config = local.glance-config +} + +module "glance-mysql-router" { + source = "../mysql-router" + + sub-name = var.app-name + model-name = var.model-name +} + +module "glance-hacluster" { + source = "../hacluster" + + sub-name = var.app-name + model-name = var.model-name +} + +resource "juju_integration" "glance-rmq" { + + model = var.model-name + + application { + name = juju_application.glance.name + endpoint = "amqp" + } + + application { + name = var.rabbitmq-server_app + endpoint = "amqp" + } + + lifecycle { + replace_triggered_by = [ + juju_application.glance.name, + juju_application.glance.model, + juju_application.glance.constraints, + juju_application.glance.placement, + juju_application.glance.charm.name, + ] + } +} + +resource "juju_integration" "glance-keystone" { + + model = var.model-name + + application { + name = juju_application.glance.name + endpoint = "identity-service" + } + + application { + name = var.keystone_app + endpoint = "identity-service" + } + + lifecycle { + replace_triggered_by = [ + juju_application.glance.name, + juju_application.glance.model, + juju_application.glance.constraints, + juju_application.glance.placement, + juju_application.glance.charm.name, + ] + } +} + +resource "juju_integration" "glance-ceph" { + + model = var.model-name + + application { + name = juju_application.glance.name + endpoint = "ceph" + } + + application { + name = var.ceph-mon_app + endpoint = "client" + } + + lifecycle { + replace_triggered_by = [ + juju_application.glance.name, + juju_application.glance.model, + juju_application.glance.constraints, + juju_application.glance.placement, + juju_application.glance.charm.name, + ] + } +} + +#resource "juju_integration" "glance-cinder" { +# +# model = var.model-name +# +# application { +# name = juju_application.glance.name +# endpoint = "image-service" +# } +# +# application { +# name = var.cinder_app +# endpoint = "image-service" +# } +# +# lifecycle { +# replace_triggered_by = [ +# juju_application.glance.name, +# juju_application.glance.model, +# juju_application.glance.constraints, +# juju_application.glance.placement, +# juju_application.glance.charm.name, +# ] +# } +#} + +resource "juju_integration" "glance-cinder-image" { + + model = var.model-name + + application { + name = juju_application.glance.name + endpoint = "cinder-volume-service" + } + + application { + name = var.cinder_app + endpoint = "cinder-volume-service" + } + + lifecycle { + replace_triggered_by = [ + juju_application.glance.name, + juju_application.glance.model, + juju_application.glance.constraints, + juju_application.glance.placement, + juju_application.glance.charm.name, + ] + } +} diff --git a/juju/home-maas-jammy/modules/glance/outputs.tf b/juju/home-maas-jammy/modules/glance/outputs.tf new file mode 100644 index 0000000..b88ea53 --- /dev/null +++ b/juju/home-maas-jammy/modules/glance/outputs.tf @@ -0,0 +1,3 @@ +output "glance" { + value = juju_application.glance +} diff --git a/juju/home-maas-jammy/modules/glance/variables.tf b/juju/home-maas-jammy/modules/glance/variables.tf new file mode 100644 index 0000000..182b3ac --- /dev/null +++ b/juju/home-maas-jammy/modules/glance/variables.tf @@ -0,0 +1,145 @@ +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 glance-channel { + type = string + default = "yogastable" +} + +variable glance-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 = "glance" +} + +variable vips { + type = map(string) + default = {} +} + +variable keystone_app { + type = string + default = "keystone" +} +variable ceph-mon_app { + type = string + default = "ceph-mon" +} +variable cinder_app { + type = string + default = "cinder" +} +variable rabbitmq-server_app { + type = string + default = "rabbitmq-server" +} + +variable glance-config-overrides { + type = map(string) + default = {} +} + +locals { + base-glance-config = { + worker-multiplier = var.worker-multiplier + openstack-origin = var.openstack-origin + region = var.openstack-region + vip = var.vips["glance"] + use-internal-endpoints = "true" + restrict-ceph-pools = "false" + } + + glance-config = merge( + local.base-glance-config, + var.glance-config-overrides + ) +} diff --git a/juju/home-maas-jammy/modules/hacluster/init.tf b/juju/home-maas-jammy/modules/hacluster/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/hacluster/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/modules/hacluster/main.tf b/juju/home-maas-jammy/modules/hacluster/main.tf new file mode 100644 index 0000000..67d62d6 --- /dev/null +++ b/juju/home-maas-jammy/modules/hacluster/main.tf @@ -0,0 +1,39 @@ +resource "juju_application" "hacluster" { + + name = "${var.app-name}-${var.sub-name}" + + model = var.model-name + + charm { + name = "hacluster" + channel = var.hacluster-channel + base = var.default-base + } + + config = var.hacluster-config +} + +resource "juju_integration" "app-ha" { + + model = var.model-name + + application { + name = var.sub-name + endpoint = "ha" + } + + application { + name = juju_application.hacluster.name + endpoint = "ha" + } + + lifecycle { + replace_triggered_by = [ + juju_application.hacluster.name, + juju_application.hacluster.model, + juju_application.hacluster.constraints, + juju_application.hacluster.placement, + juju_application.hacluster.charm.name, + ] + } +} diff --git a/juju/home-maas-jammy/modules/hacluster/outputs.tf b/juju/home-maas-jammy/modules/hacluster/outputs.tf new file mode 100644 index 0000000..ce0d965 --- /dev/null +++ b/juju/home-maas-jammy/modules/hacluster/outputs.tf @@ -0,0 +1,3 @@ +output "hacluster" { + value = juju_application.hacluster +} diff --git a/juju/home-maas-jammy/modules/hacluster/variables.tf b/juju/home-maas-jammy/modules/hacluster/variables.tf new file mode 100644 index 0000000..1d297ba --- /dev/null +++ b/juju/home-maas-jammy/modules/hacluster/variables.tf @@ -0,0 +1,84 @@ +variable model-name { + type = string + default = "openstack" +} + +variable default-base { + type = string + default = "ubuntu@22.04" +} + +variable default-series { + type = string + default = "jammy" +} + +variable mysql-router-channel { + type = string + default = "8.0/stable" +} + +variable mysql-router-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 app-name { + type = string + default = "hacluster" +} + +variable sub-name { + type = string + default = "" +} + +variable hacluster-channel { + type = string + default = "2.4/stable" +} + +variable hacluster-config { + type = map(string) + default = {} +} diff --git a/juju/home-maas-jammy/modules/keystone/init.tf b/juju/home-maas-jammy/modules/keystone/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/keystone/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/modules/keystone/main.tf b/juju/home-maas-jammy/modules/keystone/main.tf new file mode 100644 index 0000000..72c55ff --- /dev/null +++ b/juju/home-maas-jammy/modules/keystone/main.tf @@ -0,0 +1,55 @@ +resource "juju_machine" "keystone" { + count = var.num_units + model = var.model-name + placement = join(":", ["lxd", var.all_machines[var.controller_ids[count.index+var.num_units]].machine_id]) + constraints = "spaces=oam" +} + +resource "juju_application" "keystone" { + name = var.app-name + + model = var.model-name + + charm { + name = "keystone" + channel = var.keystone-channel + base = var.default-base + } + + machines = [ + for res in juju_machine.keystone : + res.machine_id + ] + + endpoint_bindings = [{ + space = var.oam-space + },{ + space = var.public-space + endpoint = "public" + },{ + space = var.admin-space + endpoint = "admin" + },{ + space = var.internal-space + endpoint = "internal" + },{ + space = var.internal-space + endpoint = "shared-db" + }] + + config = local.keystone-config +} + +module "keystone-mysql-router" { + source = "../mysql-router" + + sub-name = var.app-name + model-name = var.model-name +} + +module "keystone-hacluster" { + source = "../hacluster" + + sub-name = var.app-name + model-name = var.model-name +} diff --git a/juju/home-maas-jammy/modules/keystone/outputs.tf b/juju/home-maas-jammy/modules/keystone/outputs.tf new file mode 100644 index 0000000..1d09fc5 --- /dev/null +++ b/juju/home-maas-jammy/modules/keystone/outputs.tf @@ -0,0 +1,3 @@ +output "keystone" { + value = juju_application.keystone +} diff --git a/juju/home-maas-jammy/modules/keystone/variables.tf b/juju/home-maas-jammy/modules/keystone/variables.tf new file mode 100644 index 0000000..4d39490 --- /dev/null +++ b/juju/home-maas-jammy/modules/keystone/variables.tf @@ -0,0 +1,129 @@ +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 keystone-channel { + type = string + default = "yoga/stable" +} + +variable keystone-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 = "keystone" +} + +variable vips { + type = map(string) + default = {} +} + +variable keystone-config-overrides { + type = map(string) + default = {} +} + +locals { + base-keystone-config = { + worker-multiplier = var.worker-multiplier + openstack-origin = var.openstack-origin + region = var.openstack-region + vip = var.vips["keystone"] + preferred-api-version = "3" + token-provider = "fernet" + admin-password = "openstack" + } + + keystone-config = merge( + local.base-keystone-config, + var.keystone-config-overrides + ) +} diff --git a/juju/home-maas-jammy/modules/mysql-router/init.tf b/juju/home-maas-jammy/modules/mysql-router/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/mysql-router/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/modules/mysql-router/main.tf b/juju/home-maas-jammy/modules/mysql-router/main.tf new file mode 100644 index 0000000..1c23ba8 --- /dev/null +++ b/juju/home-maas-jammy/modules/mysql-router/main.tf @@ -0,0 +1,72 @@ +resource "juju_application" "mysql-router" { + name = "${var.sub-name}-${var.app-name}" + + model = var.model-name + + charm { + name = "mysql-router" + channel = var.mysql-router-channel + base = var.default-base + #revision = var.mysql-router-revision + } + + endpoint_bindings = [{ + space = var.oam-space + },{ + space = var.internal-space + endpoint = "shared-db" + },{ + space = var.internal-space + endpoint = "db-router" + }] + + config = local.mysql-router-config +} + +resource "juju_integration" "app-mysql" { + model = var.model-name + + application { + name = var.sub-name + endpoint = "shared-db" + } + + application { + name = juju_application.mysql-router.name + endpoint = "shared-db" + } + + lifecycle { + replace_triggered_by = [ + juju_application.mysql-router.name, + juju_application.mysql-router.model, + juju_application.mysql-router.constraints, + juju_application.mysql-router.placement, + juju_application.mysql-router.charm.name, + ] + } +} + +resource "juju_integration" "app-db" { + model = var.model-name + + application { + name = juju_application.mysql-router.name + endpoint = "db-router" + } + + application { + name = var.mysql-name + endpoint = "db-router" + } + + lifecycle { + replace_triggered_by = [ + juju_application.mysql-router.name, + juju_application.mysql-router.model, + juju_application.mysql-router.constraints, + juju_application.mysql-router.placement, + juju_application.mysql-router.charm.name, + ] + } +} diff --git a/juju/home-maas-jammy/modules/mysql-router/outputs.tf b/juju/home-maas-jammy/modules/mysql-router/outputs.tf new file mode 100644 index 0000000..b21a961 --- /dev/null +++ b/juju/home-maas-jammy/modules/mysql-router/outputs.tf @@ -0,0 +1,3 @@ +output "mysql-router" { + value = juju_application.mysql-router +} diff --git a/juju/home-maas-jammy/modules/mysql-router/variables.tf b/juju/home-maas-jammy/modules/mysql-router/variables.tf new file mode 100644 index 0000000..1cade59 --- /dev/null +++ b/juju/home-maas-jammy/modules/mysql-router/variables.tf @@ -0,0 +1,95 @@ +variable model-name { + type = string + default = "openstack" +} + +variable default-base { + type = string + default = "ubuntu@22.04" +} + +variable default-series { + type = string + default = "jammy" +} + +variable mysql-router-channel { + type = string + default = "8.0/stable" +} + +variable mysql-router-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 app-name { + type = string + default = "mysql-router" +} + +variable sub-name { + type = string + default = "" +} + +variable mysql-router-config-overrides { + type = map(string) + default = {} +} + +variable mysql-name { + type = string + default = "mysql-innodb-cluster" +} + +locals { + base-mysql-router-config = { + source = var.openstack-origin + } + + mysql-router-config = merge( + local.base-mysql-router-config, + var.mysql-router-config-overrides + ) +} diff --git a/juju/home-maas-jammy/modules/nova-compute/init.tf b/juju/home-maas-jammy/modules/nova-compute/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/nova-compute/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/modules/nova-compute/main.tf b/juju/home-maas-jammy/modules/nova-compute/main.tf new file mode 100644 index 0000000..6de534b --- /dev/null +++ b/juju/home-maas-jammy/modules/nova-compute/main.tf @@ -0,0 +1,161 @@ +resource "juju_application" "nova-compute" { + name = var.app-name + + model = var.model-name + + charm { + name = "nova-compute" + channel = var.nova-compute-channel + base = var.default-base + } + + machines = [ + for index in var.compute_ids : + var.all_machines[index].machine_id + ] + + endpoint_bindings = [{ + space = var.oam-space + },{ + space = var.internal-space + endpoint = "internal" + }] + + config = local.nova-compute-config +} + +resource "juju_application" "ovn-chassis" { + name = var.ovn-chassis-app-name + + model = var.model-name + + charm { + name = "ovn-chassis" + channel = var.ovn-chassis-channel + } + + endpoint_bindings = [{ + space = var.oam-space + }] + + config = var.ovn-chassis-config +} + +resource "juju_application" "sysconfig" { + name = var.sysconfig-app-name + + model = var.model-name + + charm { + name = "sysconfig" + channel = var.sysconfig-channel + revision = var.sysconfig-revision + } + + config = var.sysconfig-config +} + +resource "juju_integration" "compute-ovn" { + + model = var.model-name + + application { + name = juju_application.ovn-chassis.name + endpoint = "nova-compute" + } + + application { + name = juju_application.nova-compute.name + endpoint = "neutron-plugin" + } +} + +resource "juju_integration" "compute-sysconfig" { + + model = var.model-name + + application { + name = juju_application.nova-compute.name + endpoint = "juju-info" + } + + application { + name = juju_application.sysconfig.name + endpoint = "juju-info" + } +} + +resource "juju_integration" "compute-ceph-mon" { + + model = var.model-name + + application { + name = juju_application.nova-compute.name + endpoint = "ceph" + } + + application { + name = var.ceph-mon_app + endpoint = "client" + } +} + +resource "juju_integration" "chassis-central" { + + model = var.model-name + + application { + name = juju_application.ovn-chassis.name + endpoint = "ovsdb" + } + + application { + name = var.ovn-central_app + endpoint = "ovsdb" + } +} + +resource "juju_integration" "nova-compute-rmq" { + + model = var.model-name + + application { + name = juju_application.nova-compute.name + endpoint = "amqp" + } + + application { + name = var.rabbitmq-server_app + endpoint = "amqp" + } +} + +resource "juju_integration" "nova-compute-glance" { + + model = var.model-name + + application { + name = juju_application.nova-compute.name + endpoint = "image-service" + } + + application { + name = var.glance_app + endpoint = "image-service" + } +} + +resource "juju_integration" "nova-compute-cinder-ceph" { + + model = var.model-name + + application { + name = juju_application.nova-compute.name + endpoint = "ceph-access" + } + + application { + name = var.cinder-ceph_app + endpoint = "ceph-access" + } +} diff --git a/juju/home-maas-jammy/modules/nova-compute/outputs.tf b/juju/home-maas-jammy/modules/nova-compute/outputs.tf new file mode 100644 index 0000000..6c9a66b --- /dev/null +++ b/juju/home-maas-jammy/modules/nova-compute/outputs.tf @@ -0,0 +1,3 @@ +output "nova-compute" { + value = juju_application.nova-compute +} diff --git a/juju/home-maas-jammy/modules/nova-compute/variables.tf b/juju/home-maas-jammy/modules/nova-compute/variables.tf new file mode 100644 index 0000000..b851700 --- /dev/null +++ b/juju/home-maas-jammy/modules/nova-compute/variables.tf @@ -0,0 +1,214 @@ +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 compute_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 nova-compute-channel { + type = string + default = "yoga/stable" +} + +variable nova-compute-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 customize-failure-domain { + type = string + default = "true" +} + +variable reserved-host-memory { + type = string + default = "512" +} + +variable worker-multiplier { + type = string + default = "0.25" +} + +variable cpu-allocation-ratio { + type = string + default = "16.0" +} + +variable ram-allocation-ratio { + type = string + default = "2.0" +} + +variable app-name { + type = string + default = "nova-compute" +} + +variable nova-compute-config-overrides { + type = map(string) + default = {} +} + +locals { + base-nova-compute-config = { + openstack-origin = var.openstack-origin + enable-live-migration = "true" + enable-resize = "true" + migration-auth-type = "ssh" + use-internal-endpoints = "true" + libvirt-image-backend = "rbd" + restrict-ceph-pools = "false" + aa-profile-mode = "complain" + virt-type = "kvm" + customize-failure-domain = var.customize-failure-domain + reserved-host-memory = var.reserved-host-memory + cpu-allocation-ratio = var.cpu-allocation-ratio + ram-allocation-ratio = var.ram-allocation-ratio + } + + nova-compute-config = merge( + local.base-nova-compute-config, + var.nova-compute-config-overrides + ) +} + +# Dependency Apps + +variable ovn-central_app { + type = string + default = "ovn-central" +} + +variable ceph-mon_app { + type = string + default = "ceph-mon" +} + +variable glance_app { + type = string + default = "glance" +} + +variable cinder-ceph_app { + type = string + default = "cinder-ceph" +} + +variable rabbitmq-server_app { + type = string + default = "rabbitmq-server" +} + +# OVN +variable ovn-chassis-app-name { + type = string + default = "ovn-chassis" +} + +variable ovn-chassis-channel { + type = string + default = "22.03/stable" +} + +variable ovn-chassis-config { + type = map(string) + default = {} +} + +# sysconfig +variable sysconfig-app-name { + type = string + default = "sysconfig" +} + +variable sysconfig-channel { + type = string + default = "latest/stable" +} + +variable sysconfig-revision { + type = string + default = "22" +} + +variable sysconfig-config { + type = map(string) + default = {} +} diff --git a/juju/home-maas-jammy/modules/rabbitmq-server/init.tf b/juju/home-maas-jammy/modules/rabbitmq-server/init.tf new file mode 100644 index 0000000..2efaa5b --- /dev/null +++ b/juju/home-maas-jammy/modules/rabbitmq-server/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/04-rmq.tf b/juju/home-maas-jammy/modules/rabbitmq-server/main.tf similarity index 59% rename from juju/home-maas-jammy/04-rmq.tf rename to juju/home-maas-jammy/modules/rabbitmq-server/main.tf index 0c77690..6a7893c 100644 --- a/juju/home-maas-jammy/04-rmq.tf +++ b/juju/home-maas-jammy/modules/rabbitmq-server/main.tf @@ -1,12 +1,12 @@ -resource "juju_machine" "rmq" { +resource "juju_machine" "rabbitmq-server" { 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" "rabbitmq-server" { - name = "rabbitmq-server" + name = var.app-name model = var.model-name @@ -17,7 +17,7 @@ resource "juju_application" "rabbitmq-server" { } machines = [ - for res in juju_machine.rmq : + for res in juju_machine.rabbitmq-server : res.machine_id ] @@ -31,9 +31,5 @@ resource "juju_application" "rabbitmq-server" { space = var.internal-space }] - config = { - source = var.openstack-origin - min-cluster-size = "3" - cluster-partition-handling = "pause_minority" - } + config = local.rabbitmq-config } diff --git a/juju/home-maas-jammy/modules/rabbitmq-server/outputs.tf b/juju/home-maas-jammy/modules/rabbitmq-server/outputs.tf new file mode 100644 index 0000000..0490d8c --- /dev/null +++ b/juju/home-maas-jammy/modules/rabbitmq-server/outputs.tf @@ -0,0 +1,3 @@ +output "rabbitmq-server" { + value = juju_application.rabbitmq-server +} diff --git a/juju/home-maas-jammy/modules/rabbitmq-server/variables.tf b/juju/home-maas-jammy/modules/rabbitmq-server/variables.tf new file mode 100644 index 0000000..4b12842 --- /dev/null +++ b/juju/home-maas-jammy/modules/rabbitmq-server/variables.tf @@ -0,0 +1,125 @@ +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 rabbitmq-server-channel { + type = string + default = "3.9/stable" +} + +variable rabbitmq-server-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 = "rabbitmq-server" +} + +variable vips { + type = map(string) + default = {} +} + +variable rabbitmq-config-overrides { + type = map(string) + default = {} +} + +locals { + base-rabbitmq-config = { + source = var.openstack-origin + min-cluster-size = "3" + cluster-partition-handling = "pause_minority" + } + + rabbitmq-config = merge( + local.base-rabbitmq-config, + var.rabbitmq-config-overrides + ) +} diff --git a/juju/home-maas-jammy/terraform.tfvars b/juju/home-maas-jammy/terraform.tfvars index dd295aa..85fa4cd 100644 --- a/juju/home-maas-jammy/terraform.tfvars +++ b/juju/home-maas-jammy/terraform.tfvars @@ -18,6 +18,10 @@ machines = [ {machine_id=1005,constraints="tags=compute,asrock03"}, {machine_id=1006,constraints="tags=compute,asrock04"}, {machine_id=1007,constraints="tags=compute,asrock04"}, + {machine_id=2000,constraints="tags=compute,asrock01"}, + {machine_id=2001,constraints="tags=compute,asrock02"}, + {machine_id=2002,constraints="tags=compute,asrock03"}, + {machine_id=2003,constraints="tags=compute,asrock04"}, ] lma-machines = [ @@ -38,6 +42,12 @@ cinder-lvm-machines = [ {machine_id=502,constraints="tags=compute,asrock04",base="ubuntu@22.04"}, ] +controller_ids = [ 100, 101, 102, 103, 104, 105 ] +sdn_ids = [ 400, 401, 402] +k8s_ids = [ 300, 301, 302] +compute_ids = [ 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007] +dpdk_ids = [ 2000, 2001, 2002, 2003] + infra-machines = [ "asrock01", "asrock02", @@ -71,6 +81,9 @@ dns-servers = "192.168.1.13" data-port = "br-data:ens9" bridge-mappings = "physnet1:br-data" +#nova-default-filters = "RetryFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,DifferentHostFilter,SameHostFilter,AggregateInstanceExtraSpecsFilter,PciPassthroughFilter,NUMATopologyFilter" +#nova-default-filters = "RetryFilter,AvailabilityZoneFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,DifferentHostFilter,SameHostFilter,AggregateInstanceExtraSpecsFilter,PciPassthroughFilter,NUMATopologyFilter" + vips = { aodh = "10.0.1.211" cinder = "10.0.1.212" diff --git a/openstack/init/user-data.yaml b/openstack/user-data.yaml similarity index 100% rename from openstack/init/user-data.yaml rename to openstack/user-data.yaml