diff --git a/juju/home-maas-jammy/.gitignore b/juju/home-maas-jammy/.gitignore new file mode 100644 index 0000000..b75f170 --- /dev/null +++ b/juju/home-maas-jammy/.gitignore @@ -0,0 +1,23 @@ +.bak +.old +05-cinder-ceph2.tf +05-cinder-lvm.tf +09-filebeat.tf +09-telegraf.tf +20-model.tf +21-machines.tf +22-graylog.tf +23-elastic.tf +24-grafana.tf +25-prometheus.tf +30-model.tf +31-machines.tf +32-microk8s.tf +33-ceph.tf +34-ntp.tf +35-grafana-agent.tf +41-ldap.tf +50-model.tf +51-machines.tf +52-infra-nodes.tf +53-ntp.tf diff --git a/juju/home-maas-jammy/00-init.tf b/juju/home-maas-jammy/00-init.tf index 33c9c39..5931783 100644 --- a/juju/home-maas-jammy/00-init.tf +++ b/juju/home-maas-jammy/00-init.tf @@ -1,9 +1,8 @@ terraform { required_providers { juju = { - version = "~> 0.15.0" + version = "~> 0.19.0" source = "juju/juju" - } } } diff --git a/juju/home-maas-jammy/00-variables.tf b/juju/home-maas-jammy/00-variables.tf index 4ca0cec..0ca1100 100644 --- a/juju/home-maas-jammy/00-variables.tf +++ b/juju/home-maas-jammy/00-variables.tf @@ -88,6 +88,19 @@ variable "microk8s-machines" { })) } +variable "cinder-lvm-machines" { + type = list(object({ + machine_id = number + constraints = string + base = optional(string) + })) +} + +variable infra-machines { + type = list(string) + default = [] +} + variable model-name { type = string default = "openstack" @@ -103,6 +116,11 @@ variable microk8s-model-name { default = "microk8s" } +variable infra-model-name { + type = string + default = "infra" +} + variable openstack-origin { type = string default = "distro" @@ -128,6 +146,11 @@ variable default-base { default = "ubuntu@22.04" } +variable default-series { + type = string + default = "jammy" +} + variable mysql-channel { type = string default = "8.0/stable" diff --git a/juju/home-maas-jammy/01-cloud.tf b/juju/home-maas-jammy/01-cloud.tf index a970c6c..248f102 100644 --- a/juju/home-maas-jammy/01-cloud.tf +++ b/juju/home-maas-jammy/01-cloud.tf @@ -16,5 +16,12 @@ resource "juju_model" "openstack" { #agent-metadata-url = "http://${var.apt_mirror}/juju/tools/" agent-stream = "released" + + default-series = var.default-series } } + +resource "juju_ssh_key" "aarsa4096canonical" { + model = juju_model.openstack.name + payload = file("/home/arif/.ssh/aarsa4096canonical.pub") +} diff --git a/juju/home-maas-jammy/04-keystone.tf b/juju/home-maas-jammy/04-keystone.tf index 0c7c2a7..d9e2ff1 100644 --- a/juju/home-maas-jammy/04-keystone.tf +++ b/juju/home-maas-jammy/04-keystone.tf @@ -16,12 +16,10 @@ resource "juju_application" "keystone" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.keystone : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -60,8 +58,6 @@ resource "juju_application" "keystone-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space },{ @@ -86,8 +82,6 @@ resource "juju_application" "hacluster-keystone" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } resource "juju_integration" "keystone-ha" { diff --git a/juju/home-maas-jammy/04-mysql.tf b/juju/home-maas-jammy/04-mysql.tf index 277d0ff..0ead7bc 100644 --- a/juju/home-maas-jammy/04-mysql.tf +++ b/juju/home-maas-jammy/04-mysql.tf @@ -16,12 +16,10 @@ resource "juju_application" "mysql-innodb-cluster" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.mysql : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space diff --git a/juju/home-maas-jammy/04-rmq.tf b/juju/home-maas-jammy/04-rmq.tf index bd9fc48..0c77690 100644 --- a/juju/home-maas-jammy/04-rmq.tf +++ b/juju/home-maas-jammy/04-rmq.tf @@ -16,12 +16,10 @@ resource "juju_application" "rabbitmq-server" { base = var.default-base } - units = 3 - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.rmq : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space diff --git a/juju/home-maas-jammy/05-ceph.tf b/juju/home-maas-jammy/05-ceph.tf index 5dfee2b..d282fca 100644 --- a/juju/home-maas-jammy/05-ceph.tf +++ b/juju/home-maas-jammy/05-ceph.tf @@ -9,12 +9,10 @@ resource "juju_application" "ceph-osd" { base = var.default-base } - units = length(var.compute_ids) - - placement = "${join(",", sort([ + machines = [ for index in var.compute_ids : juju_machine.all_machines[index].machine_id - ]))}" + ] config = { osd-devices = var.osd-devices @@ -46,12 +44,10 @@ resource "juju_application" "ceph-mon" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.ceph-mon : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -98,12 +94,10 @@ resource "juju_application" "ceph-radosgw" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.ceph-rgw : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -141,8 +135,6 @@ resource "juju_application" "hacluster-radosgw" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } resource "juju_integration" "osd-mon" { diff --git a/juju/home-maas-jammy/05-cinder-backup.tf b/juju/home-maas-jammy/05-cinder-backup.tf index 4b98689..e2c9841 100644 --- a/juju/home-maas-jammy/05-cinder-backup.tf +++ b/juju/home-maas-jammy/05-cinder-backup.tf @@ -16,12 +16,10 @@ resource "juju_application" "cinder-backup" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.cinder-backup : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -60,8 +58,6 @@ resource "juju_application" "cinder-backup-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space },{ diff --git a/juju/home-maas-jammy/05-cinder.tf b/juju/home-maas-jammy/05-cinder.tf index 994e153..f80671c 100644 --- a/juju/home-maas-jammy/05-cinder.tf +++ b/juju/home-maas-jammy/05-cinder.tf @@ -16,12 +16,10 @@ resource "juju_application" "cinder" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.cinder : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -61,8 +59,6 @@ resource "juju_application" "cinder-ceph" { channel = var.openstack-channel } - units = 0 - config = { restrict-ceph-pools = "false" } @@ -79,8 +75,6 @@ resource "juju_application" "cinder-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space },{ @@ -105,8 +99,6 @@ resource "juju_application" "hacluster-cinder" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } resource "juju_integration" "cinder-ha" { diff --git a/juju/home-maas-jammy/05-glance.tf b/juju/home-maas-jammy/05-glance.tf index dc19649..5b3719d 100644 --- a/juju/home-maas-jammy/05-glance.tf +++ b/juju/home-maas-jammy/05-glance.tf @@ -2,7 +2,7 @@ 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 = "spaces=oam" + constraints = "cores=2 mem=2048M spaces=oam virt-type=virtual-machine" } resource "juju_application" "glance" { @@ -16,12 +16,10 @@ resource "juju_application" "glance" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.glance : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -59,8 +57,6 @@ resource "juju_application" "glance-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space },{ @@ -85,8 +81,6 @@ resource "juju_application" "hacluster-glance" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } resource "juju_integration" "glance-ha" { @@ -180,17 +174,32 @@ resource "juju_integration" "glance-ceph" { } } -resource "juju_integration" "glance-cinder" { +#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 = "image-service" + endpoint = "cinder-volume-service" } application { name = juju_application.cinder.name - endpoint = "image-service" + endpoint = "cinder-volume-service" } } diff --git a/juju/home-maas-jammy/05-heat.tf b/juju/home-maas-jammy/05-heat.tf index d20d51f..79eecad 100644 --- a/juju/home-maas-jammy/05-heat.tf +++ b/juju/home-maas-jammy/05-heat.tf @@ -16,12 +16,10 @@ resource "juju_application" "heat" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.heat : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -59,8 +57,6 @@ resource "juju_application" "heat-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space },{ @@ -85,8 +81,6 @@ resource "juju_application" "hacluster-heat" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } resource "juju_integration" "heat-ha" { diff --git a/juju/home-maas-jammy/05-memcache.tf b/juju/home-maas-jammy/05-memcache.tf index b8efaab..397e0e3 100644 --- a/juju/home-maas-jammy/05-memcache.tf +++ b/juju/home-maas-jammy/05-memcache.tf @@ -16,12 +16,10 @@ resource "juju_application" "memcached" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.memcache : res.machine_id - ]))}" + ] endpoint_bindings = [{ diff --git a/juju/home-maas-jammy/05-nova.tf b/juju/home-maas-jammy/05-nova.tf index d833a28..e777bac 100644 --- a/juju/home-maas-jammy/05-nova.tf +++ b/juju/home-maas-jammy/05-nova.tf @@ -16,12 +16,10 @@ resource "juju_application" "nova-cloud-controller" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.ncc : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -67,8 +65,6 @@ resource "juju_application" "nova-cloud-controller-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space },{ @@ -93,8 +89,6 @@ resource "juju_application" "hacluster-nova" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } resource "juju_integration" "nova-cloud-controller-ha" { diff --git a/juju/home-maas-jammy/05-placement.tf b/juju/home-maas-jammy/05-placement.tf index e702425..2a70167 100644 --- a/juju/home-maas-jammy/05-placement.tf +++ b/juju/home-maas-jammy/05-placement.tf @@ -16,12 +16,10 @@ resource "juju_application" "placement" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.placement : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -60,8 +58,6 @@ resource "juju_application" "placement-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space },{ @@ -86,8 +82,6 @@ resource "juju_application" "hacluster-placement" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } resource "juju_integration" "placement-ha" { diff --git a/juju/home-maas-jammy/06-nova-compute.tf b/juju/home-maas-jammy/06-nova-compute.tf index de50f99..3c11b72 100644 --- a/juju/home-maas-jammy/06-nova-compute.tf +++ b/juju/home-maas-jammy/06-nova-compute.tf @@ -9,12 +9,10 @@ resource "juju_application" "nova-compute-kvm" { base = var.default-base } - units = length(var.compute_ids) - - placement = "${join(",", sort([ + machines = [ for index in var.compute_ids : juju_machine.all_machines[index].machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -37,21 +35,6 @@ resource "juju_application" "nova-compute-kvm" { reserved-host-memory = var.reserved-host-memory cpu-allocation-ratio = var.cpu-allocation-ratio ram-allocation-ratio = var.ram-allocation-ratio - #cpu-mode = "custom" - #cpu-model = "EPYC-IBPB" - #cpu-model-extra-flags = "svm,pcid" - pci-passthrough-whitelist = jsonencode([ - {vendor_id: "1af4", product_id: "1000", address: "00:08.0"}, - {vendor_id: "1af4", product_id: "1000", address: "00:07.0"}, - {vendor_id: "1af4", product_id: "1000", address: "00:06.0"}, - ]) - pci-alias = jsonencode({ - vendor_id: "1af4", - product_id: "1000", - device_type: "type-PCI", - name: "arifpass", - numa_policy: "preferred" - }) } } @@ -65,8 +48,6 @@ resource "juju_application" "ovn-chassis" { channel = var.ovn-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space }] @@ -88,8 +69,6 @@ resource "juju_application" "sysconfig-compute" { revision = var.sysconfig_revision } - units = 0 - config = { # enable-iommu = "false" governor = "performance" diff --git a/juju/home-maas-jammy/06-openstack-dashboard.tf b/juju/home-maas-jammy/06-openstack-dashboard.tf index 8473103..d86b6f1 100644 --- a/juju/home-maas-jammy/06-openstack-dashboard.tf +++ b/juju/home-maas-jammy/06-openstack-dashboard.tf @@ -16,12 +16,10 @@ resource "juju_application" "openstack-dashboard" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.openstack-dashboard : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -55,8 +53,6 @@ resource "juju_application" "openstack-dashboard-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space },{ @@ -81,8 +77,6 @@ resource "juju_application" "hacluster-openstack-dashboard" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } resource "juju_integration" "openstack-dashboard-ha" { diff --git a/juju/home-maas-jammy/07-controllers.tf b/juju/home-maas-jammy/07-controllers.tf index 3453d5f..68b91e0 100644 --- a/juju/home-maas-jammy/07-controllers.tf +++ b/juju/home-maas-jammy/07-controllers.tf @@ -10,12 +10,10 @@ resource "juju_application" "controller-server" { base = var.default-base } - units = length(var.controller_ids) - - placement = "${join(",", sort([ + machines = [ for index in var.controller_ids : juju_machine.all_machines[index].machine_id - ]))}" + ] } resource "juju_application" "sysconfig-control" { @@ -29,8 +27,6 @@ resource "juju_application" "sysconfig-control" { revision = var.sysconfig_revision } - units = 0 - config = { governor = "performance" enable-pti = "on" diff --git a/juju/home-maas-jammy/08-neutron.tf b/juju/home-maas-jammy/08-neutron.tf index aebac3e..416d449 100644 --- a/juju/home-maas-jammy/08-neutron.tf +++ b/juju/home-maas-jammy/08-neutron.tf @@ -16,12 +16,10 @@ resource "juju_application" "ovn-central" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.ovn-central : res.machine_id - ]))}" + ] } @@ -43,12 +41,10 @@ resource "juju_application" "neutron-api" { base = var.default-base } - units = var.num_units - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.neutron-api : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -97,8 +93,6 @@ resource "juju_application" "neutron-api-plugin-ovn" { channel = var.openstack-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space }] @@ -115,8 +109,6 @@ resource "juju_application" "neutron-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [{ space = var.oam-space },{ @@ -141,8 +133,6 @@ resource "juju_application" "hacluster-neutron" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } resource "juju_integration" "neutron-ha" { diff --git a/juju/home-maas-jammy/10-vault.tf b/juju/home-maas-jammy/10-vault.tf index 864ad6c..af8e555 100644 --- a/juju/home-maas-jammy/10-vault.tf +++ b/juju/home-maas-jammy/10-vault.tf @@ -17,12 +17,10 @@ resource "juju_application" "vault" { revision = 319 } - units = var.num_units - - placement = "${join(",",sort([ + machines = [ for res in juju_machine.vault : res.machine_id - ]))}" + ] config = { vip = var.vips["vault"] @@ -42,8 +40,6 @@ resource "juju_application" "vault-mysql-router" { channel = var.mysql-router-channel } - units = 0 - endpoint_bindings = [ { space = var.oam-space @@ -70,8 +66,6 @@ resource "juju_application" "hacluster-vault" { name = "hacluster" channel = var.hacluster-channel } - - units = 0 } @@ -94,10 +88,10 @@ resource "juju_application" "etcd" { #revision = var.etcd_revision } - placement = "${join(",",sort([ + machines = [ for res in juju_machine.etcd : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -109,8 +103,6 @@ resource "juju_application" "etcd" { endpoint = "db" }] - units = var.num_units - config = { channel = "3.2/stable" } @@ -133,11 +125,9 @@ resource "juju_application" "easyrsa" { base = var.default-base } - placement = juju_machine.easyrsa.machine_id + machines = [ juju_machine.easyrsa.machine_id ] endpoint_bindings = [{space = var.oam-space}] - - units = 1 } resource "juju_integration" "vault-etcd" { diff --git a/juju/home-maas-jammy/additional/05-cinder-ceph2.tf b/juju/home-maas-jammy/additional/05-cinder-ceph2.tf new file mode 100644 index 0000000..0e09c7b --- /dev/null +++ b/juju/home-maas-jammy/additional/05-cinder-ceph2.tf @@ -0,0 +1,60 @@ +resource "juju_application" "cinder-ceph-pool2" { + name = "cinder-ceph-pool2" + + model = var.model-name + + charm { + name = "cinder-ceph" + channel = var.openstack-channel + } + + config = { + restrict-ceph-pools = "false" + rbd-pool-name = "pool2" + } +} + +resource "juju_integration" "cinder-ceph-pool2-mon" { + + model = var.model-name + + application { + name = juju_application.cinder-ceph-pool2.name + endpoint = "ceph" + } + + application { + name = juju_application.ceph-mon.name + endpoint = "client" + } +} + +resource "juju_integration" "cinder-ceph-pool2-cinder" { + + model = var.model-name + + application { + name = juju_application.cinder-ceph-pool2.name + endpoint = "storage-backend" + } + + application { + name = juju_application.cinder.name + endpoint = "storage-backend" + } +} + +resource "juju_integration" "nova-compute-cinder-ceph-pool2" { + + model = var.model-name + + application { + name = juju_application.nova-compute-kvm.name + endpoint = "ceph-access" + } + + application { + name = juju_application.cinder-ceph-pool2.name + endpoint = "ceph-access" + } +} diff --git a/juju/home-maas-jammy/additional/05-cinder-lvm.tf b/juju/home-maas-jammy/additional/05-cinder-lvm.tf new file mode 100644 index 0000000..b715e14 --- /dev/null +++ b/juju/home-maas-jammy/additional/05-cinder-lvm.tf @@ -0,0 +1,173 @@ +resource "juju_machine" "cinder-volume" { + for_each = { + for index, machine in var.cinder-lvm-machines: + machine.machine_id => machine + } + model = juju_model.openstack.name + name = each.value.machine_id + constraints = each.value.constraints + base = each.value.base +} + +resource "juju_application" "cinder-volume" { + name = "cinder-volume" + + model = var.model-name + + charm { + name = "cinder" + channel = var.openstack-channel + base = var.default-base + } + + machines = [ + for res in juju_machine.cinder-volume : + 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 = "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" + + model = var.model-name + + charm { + name = "cinder-lvm" + channel = var.openstack-channel + } + + config = { + alias = "deepfield" + block-device = "/dev/sdb /dev/sdc" + unique-backend = "False" + erase-size = "50" + } +} + +resource "juju_integration" "cinder-lvm-vol" { + + model = var.model-name + + application { + name = juju_application.cinder-lvm.name + endpoint = "storage-backend" + } + + application { + name = juju_application.cinder-volume.name + endpoint = "storage-backend" + } +} + +resource "juju_integration" "cinder-vol-mysql" { + + 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" + } +} + +resource "juju_integration" "cinder-vol-db" { + + 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" + } +} + +resource "juju_integration" "cinder-vol-rmq" { + + model = var.model-name + + application { + name = juju_application.cinder-volume.name + endpoint = "amqp" + } + + application { + name = juju_application.rabbitmq-server.name + endpoint = "amqp" + } +} + +resource "juju_integration" "cinder-vol-keystone" { + + model = var.model-name + + application { + name = juju_application.cinder-volume.name + endpoint = "identity-credentials" + } + + application { + name = juju_application.keystone.name + endpoint = "identity-credentials" + } +} + diff --git a/juju/home-maas-jammy/bundle.yaml b/juju/home-maas-jammy/bundle.yaml new file mode 100644 index 0000000..40a2b9b --- /dev/null +++ b/juju/home-maas-jammy/bundle.yaml @@ -0,0 +1,28 @@ +variables: + oam-space: &oam-space oam + internal-space: &internal-space oam + +applications: + cinder: + charm: ch:cinder + channel: yoga/stable + series: jammy + bindings: + "": *oam-space + num_units: 0 + cinder-backup: + charm: ch:cinder + channel: yoga/stable + series: jammy + bindings: + "": *oam-space + num_units: 0 + etcd: + charm: ch:etcd + channel: 1.29/stable + series: jammy + bindings: + "": *oam-space + cluster: *internal-space + db: *internal-space + num_units: 0 diff --git a/juju/home-maas-jammy/cinder-volume.yaml b/juju/home-maas-jammy/cinder-volume.yaml new file mode 100644 index 0000000..dccafbf --- /dev/null +++ b/juju/home-maas-jammy/cinder-volume.yaml @@ -0,0 +1,11 @@ +variables: + oam-space: &oam-space oam + +applications: + cinder-volume: + charm: ch:cinder + channel: yoga/stable + series: jammy + bindings: + "": *oam-space + num_units: 0 diff --git a/juju/home-maas-jammy/cos/00-init.tf b/juju/home-maas-jammy/cos/00-init.tf deleted file mode 120000 index cd1a1d4..0000000 --- a/juju/home-maas-jammy/cos/00-init.tf +++ /dev/null @@ -1 +0,0 @@ -../../init.tf \ No newline at end of file diff --git a/juju/home-maas-jammy/cos/00-variables.tf b/juju/home-maas-jammy/cos/00-variables.tf deleted file mode 100644 index 799630b..0000000 --- a/juju/home-maas-jammy/cos/00-variables.tf +++ /dev/null @@ -1,37 +0,0 @@ -variable cloud { - type = string - default = "home-maas" -} - -variable "mk8s-machines" { - type = list(object({ - machine_id = number - constraints = string - })) -} - -variable mk8s-model-name { - type = string - default = "microk8s" -} - -variable default-base { - type = string - default = "ubuntu@22.04" -} - -variable oam-space { - type = string - default = "oam" -} - -variable apt_mirror { - type = string - default = "192.168.1.12" -} - -variable lxd-snap-channel { - type = string - default = "5.21/stable" -} - diff --git a/juju/home-maas-jammy/cos/20-microk8s.tf b/juju/home-maas-jammy/cos/20-microk8s.tf deleted file mode 100644 index 4ecc41a..0000000 --- a/juju/home-maas-jammy/cos/20-microk8s.tf +++ /dev/null @@ -1,139 +0,0 @@ -resource "juju_model" "microk8s" { - name = var.mk8s-model-name - - cloud { - name = var.cloud - } - - config = { - apt-mirror = "http://${var.apt_mirror}/archive.ubuntu.com/ubuntu" - lxd-snap-channel = var.lxd-snap-channel - - container-image-metadata-url = "http://${var.apt_mirror}/lxd/" - container-image-stream = "released" - - agent-metadata-url = "http://${var.apt_mirror}/juju/tools/" - agent-stream = "released" - } -} - - -resource "juju_machine" "mk8s" { - for_each = { - for index, machine in var.mk8s-machines: - machine.machine_id => machine - } - model = juju_model.microk8s.name - name = each.value.machine_id - constraints = each.value.constraints - #base = each.value.base -} - -resource "juju_application" "microk8s" { - name = "microk8s" - - model = juju_model.microk8s.name - - charm { - name = "microk8s" - channel = "1.28/stable" - base = var.default-base - } - - units = 4 - - placement = "${join(",", sort([ - for res in juju_machine.mk8s : - res.machine_id - ]))}" - - config = { - hostpath_storage = "true" - } -} - -resource "juju_application" "microceph" { - name = "microceph" - - model = juju_model.microk8s.name - - endpoint_bindings = [{ - "space" = var.oam-space - }] - - charm { - name = "microceph" - channel = "latest/edge" - base = var.default-base - } - - units = 4 - - placement = "${join(",", sort([ - for res in juju_machine.mk8s : - res.machine_id - ]))}" - - config = { - snap-channel = "latest/stable" - } -} - -resource "juju_machine" "cos-proxy" { - model = juju_model.microk8s.name - placement = "${join(":",["lxd", tolist(sort([ - for res in juju_machine.mk8s : - res.machine_id - ]))[0]])}" - constraints = "spaces=oam" -} - -resource "juju_application" "cos-proxy" { - name = "cos-proxy" - - model = juju_model.microk8s.name - - charm { - name = "cos-proxy" - channel = "latest/edge" - base = var.default-base - } - - units = 1 - - placement = juju_machine.cos-proxy.machine_id -} - -resource "juju_application" "ntp" { - name = "ntp" - - model = juju_model.microk8s.name - - charm { - name = "ntp" - channel = "latest/stable" - base = var.default-base - } - - units = 0 - - config = { - pools = "ntp.canonical.com" - verify_ntp_servers = "true" - } -} - -resource "juju_integration" "ntp-k8s" { - - model = juju_model.microk8s.name - - application { - name = juju_application.microk8s.name - endpoint = "juju-info" - } - - application { - name = juju_application.ntp.name - endpoint = "juju-info" - } -} diff --git a/juju/home-maas-jammy/cos/terraform.tfvars b/juju/home-maas-jammy/cos/terraform.tfvars deleted file mode 100644 index 4f4a1ca..0000000 --- a/juju/home-maas-jammy/cos/terraform.tfvars +++ /dev/null @@ -1,8 +0,0 @@ -mk8s-machines = [ - {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"}, -] - -mk8s-model-name = "microk8s" diff --git a/juju/home-maas-jammy/deploy_manual.sh b/juju/home-maas-jammy/deploy_manual.sh new file mode 100755 index 0000000..5c37732 --- /dev/null +++ b/juju/home-maas-jammy/deploy_manual.sh @@ -0,0 +1,7 @@ +echo juju deploy ./bundle.yaml +apps="etcd cinder-backup cinder" +for app in ${apps} ; do + echo tf import juju_application.${app} cpe-jammy:${app} + machines=$(cat terraform.tfstate | jq -rc '.resources[] | select(.type == "juju_machine" and .name == "'${app}'") | .instances[].attributes.machine_id' | xargs | tr ' ' ',') + echo juju deploy ${app} -n 3 --to ${machines} +done diff --git a/juju/home-maas-jammy/infra/50-model.tf b/juju/home-maas-jammy/infra/50-model.tf new file mode 100644 index 0000000..6840d53 --- /dev/null +++ b/juju/home-maas-jammy/infra/50-model.tf @@ -0,0 +1,18 @@ +resource "juju_model" "infra" { + name = var.infra-model-name + + cloud { + name = var.cloud + } + + config = { + apt-mirror = "http://${var.apt_mirror}/archive.ubuntu.com/ubuntu" + lxd-snap-channel = var.lxd-snap-channel + + container-image-metadata-url = "http://${var.apt_mirror}/lxd/" + container-image-stream = "released" + + agent-metadata-url = "http://${var.apt_mirror}/juju/tools/" + agent-stream = "released" + } +} diff --git a/juju/home-maas-jammy/infra/51-machines.tf b/juju/home-maas-jammy/infra/51-machines.tf new file mode 100644 index 0000000..6e41f33 --- /dev/null +++ b/juju/home-maas-jammy/infra/51-machines.tf @@ -0,0 +1,9 @@ +resource "juju_machine" "infra" { + for_each = toset(var.infra-machines) + + model = juju_model.infra.name + + ssh_address = "ubuntu@${each.value}" + private_key_file = "/home/arif/.ssh/aarsa4096canonical" + public_key_file = "/home/arif/.ssh/aarsa4096canonical.pub" +} diff --git a/juju/home-maas-jammy/infra/52-infra-nodes.tf b/juju/home-maas-jammy/infra/52-infra-nodes.tf new file mode 100644 index 0000000..96ef177 --- /dev/null +++ b/juju/home-maas-jammy/infra/52-infra-nodes.tf @@ -0,0 +1,18 @@ +resource "juju_application" "infra-server" { + name = "infra-server" + + model = juju_model.infra.name + + charm { + name = "ubuntu" + channel = var.ubuntu_channel + revision = var.ubuntu_revision + base = var.default-base + } + + machines = [ + for res in juju_machine.infra : + res.machine_id + ] + +} diff --git a/juju/home-maas-jammy/infra/53-ntp.tf b/juju/home-maas-jammy/infra/53-ntp.tf new file mode 100644 index 0000000..4e8a46b --- /dev/null +++ b/juju/home-maas-jammy/infra/53-ntp.tf @@ -0,0 +1,27 @@ +resource "juju_application" "infra-ntp" { + name = "ntp" + + model = juju_model.infra.name + + charm { + name = "ntp" + channel = "latest/stable" + base = "ubuntu@22.04" + } +} + +resource "juju_integration" "infra-ntp-rel" { + + model = juju_model.infra.name + + application { + name = juju_application.infra-ntp.name + endpoint = "juju-info" + } + + application { + name = juju_application.infra-server.name + endpoint = "juju-info" + } +} + diff --git a/juju/home-maas-jammy/ldap/41-ldap.tf b/juju/home-maas-jammy/ldap/41-ldap.tf new file mode 100644 index 0000000..c342d4f --- /dev/null +++ b/juju/home-maas-jammy/ldap/41-ldap.tf @@ -0,0 +1,53 @@ +resource "juju_application" "keystone-ldap-domain1" { + name = "keystone-ldap-domain1" + + model = var.model-name + + charm { + name = "keystone-ldap" + channel = var.openstack-channel + base = var.default-base + } + + config = { + + ldap-user = "cn=admin,dc=test,dc=com" + ldap-password = "crapper" + ldap-suffix = "dc=test,dc=com" + domain-name = "domain1" + ldap-server = "ldap://10.0.1.209" + ldap-config-flags = jsonencode({ + use_pool: true, + pool_size: 10, + pool_retry_max: 1, + user_tree_dn: "ou=users,dc=test,dc=com", + user_objectclass: "posixAccount", + user_id_attribute: "uid", + user_name_attribute: "uid", + user_attribute_ignore: "userPassword", + query_scope: "sub", + group_name_attribute: "cn", + group_member_attribute: "memberUid", + group_desc_attribute: "description", + group_tree_dn: "ou=groups,dc=test,dc=com", + group_id_attribute: "cn", + group_objectclass: "posixGroup", + group_members_are_ids: true + }) + } +} + +resource "juju_integration" "keystone-ldap-domain1" { + + model = var.model-name + + application { + name = juju_application.keystone.name + endpoint = "domain-backend" + } + + application { + name = juju_application.keystone-ldap-domain1.name + endpoint = "domain-backend" + } +} diff --git a/juju/home-maas-jammy/microk8s/00-init.tf b/juju/home-maas-jammy/microk8s/00-init.tf new file mode 120000 index 0000000..b015707 --- /dev/null +++ b/juju/home-maas-jammy/microk8s/00-init.tf @@ -0,0 +1 @@ +../00-init.tf \ No newline at end of file diff --git a/juju/home-maas-jammy/microk8s/00-variables.tf b/juju/home-maas-jammy/microk8s/00-variables.tf new file mode 120000 index 0000000..33103d8 --- /dev/null +++ b/juju/home-maas-jammy/microk8s/00-variables.tf @@ -0,0 +1 @@ +../00-variables.tf \ No newline at end of file diff --git a/juju/home-maas-jammy/microk8s/32-microk8s.tf b/juju/home-maas-jammy/microk8s/32-microk8s.tf index 2770d7c..f71ff00 100644 --- a/juju/home-maas-jammy/microk8s/32-microk8s.tf +++ b/juju/home-maas-jammy/microk8s/32-microk8s.tf @@ -9,12 +9,10 @@ resource "juju_application" "microk8s" { base = "ubuntu@22.04" } - units = 3 - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.microk8s : res.machine_id - ]))}" + ] endpoint_bindings = [{ diff --git a/juju/home-maas-jammy/microk8s/33-ceph.tf b/juju/home-maas-jammy/microk8s/33-ceph.tf index 9a2310a..56f4c6f 100644 --- a/juju/home-maas-jammy/microk8s/33-ceph.tf +++ b/juju/home-maas-jammy/microk8s/33-ceph.tf @@ -1,4 +1,4 @@ -resource "juju_application" "ceph-osd" { +resource "juju_application" "mk8s-ceph-osd" { name = "ceph-osd" model = juju_model.microk8s.name @@ -9,19 +9,17 @@ resource "juju_application" "ceph-osd" { base = var.default-base } - units = length(juju_machine.microk8s) - - placement = "${join(",", sort([ + machines = [ for res in juju_machine.microk8s : res.machine_id - ]))}" + ] config = { osd-devices = var.osd-devices } } -resource "juju_machine" "ceph-mon" { +resource "juju_machine" "mk8s-ceph-mon" { count = length(juju_machine.microk8s) model = juju_model.microk8s.name placement = join(":", ["lxd", juju_machine.microk8s[var.k8s_ids[count.index]].machine_id]) @@ -29,7 +27,7 @@ resource "juju_machine" "ceph-mon" { base = var.default-base } -resource "juju_application" "ceph-mon" { +resource "juju_application" "mk8s-ceph-mon" { name = "ceph-mon" model = juju_model.microk8s.name @@ -40,12 +38,10 @@ resource "juju_application" "ceph-mon" { base = var.default-base } - units = length(juju_machine.microk8s) - - placement = "${join(",", sort([ - for res in juju_machine.ceph-mon : + machines = [ + for res in juju_machine.mk8s-ceph-mon : res.machine_id - ]))}" + ] endpoint_bindings = [{ space = var.oam-space @@ -57,7 +53,7 @@ resource "juju_application" "ceph-mon" { } } -resource "juju_application" "ceph-csi" { +resource "juju_application" "mk8s-ceph-csi" { name = "ceph-csi" model = juju_model.microk8s.name @@ -68,50 +64,48 @@ resource "juju_application" "ceph-csi" { base = var.default-base } - units = 0 - config = { provisioner-replicas = 1 namespace = "kube-system" } } -resource "juju_integration" "osd-mon" { +resource "juju_integration" "mk8s-osd-mon" { model = juju_model.microk8s.name application { - name = juju_application.ceph-osd.name + name = juju_application.mk8s-ceph-osd.name endpoint = "mon" } application { - name = juju_application.ceph-mon.name + name = juju_application.mk8s-ceph-mon.name endpoint = "osd" } } -resource "juju_integration" "csi-mon" { +resource "juju_integration" "mk8s-csi-mon" { model = juju_model.microk8s.name application { - name = juju_application.ceph-csi.name + name = juju_application.mk8s-ceph-csi.name endpoint = "ceph-client" } application { - name = juju_application.ceph-mon.name + name = juju_application.mk8s-ceph-mon.name endpoint = "client" } } -resource "juju_integration" "csi-k8s" { +resource "juju_integration" "mk8s-csi-k8s" { model = juju_model.microk8s.name application { - name = juju_application.ceph-csi.name + name = juju_application.mk8s-ceph-csi.name endpoint = "kubernetes-info" } diff --git a/juju/home-maas-jammy/microk8s/34-ntp.tf b/juju/home-maas-jammy/microk8s/34-ntp.tf index 003d878..3bb6f6e 100644 --- a/juju/home-maas-jammy/microk8s/34-ntp.tf +++ b/juju/home-maas-jammy/microk8s/34-ntp.tf @@ -8,8 +8,6 @@ resource "juju_application" "ntp" { channel = "latest/stable" base = "ubuntu@22.04" } - - units = 0 } resource "juju_integration" "ntp-k8s" { diff --git a/juju/home-maas-jammy/microk8s/35-grafana-agent.tf b/juju/home-maas-jammy/microk8s/35-grafana-agent.tf new file mode 100644 index 0000000..7f1896b --- /dev/null +++ b/juju/home-maas-jammy/microk8s/35-grafana-agent.tf @@ -0,0 +1,27 @@ +resource "juju_application" "grafana-agent" { + name = "grafana-agent" + + model = juju_model.microk8s.name + + charm { + name = "grafana-agent" + channel = "1/stable" + base = "ubuntu@22.04" + } +} + +resource "juju_integration" "grafana-agent-k8s" { + + model = juju_model.microk8s.name + + application { + name = juju_application.grafana-agent.name + endpoint = "juju-info" + } + + application { + name = juju_application.microk8s.name + endpoint = "juju-info" + } +} + diff --git a/juju/home-maas-jammy/microk8s/terraform.tfvars b/juju/home-maas-jammy/microk8s/terraform.tfvars new file mode 120000 index 0000000..ac9c2a0 --- /dev/null +++ b/juju/home-maas-jammy/microk8s/terraform.tfvars @@ -0,0 +1 @@ +../terraform.tfvars \ No newline at end of file diff --git a/juju/home-maas-jammy/terraform.tfvars b/juju/home-maas-jammy/terraform.tfvars index b6832e6..dd295aa 100644 --- a/juju/home-maas-jammy/terraform.tfvars +++ b/juju/home-maas-jammy/terraform.tfvars @@ -32,6 +32,19 @@ microk8s-machines = [ {machine_id=302,constraints="tags=compute,asrock01",base="ubuntu@22.04"}, ] +cinder-lvm-machines = [ + {machine_id=500,constraints="tags=compute,asrock01",base="ubuntu@22.04"}, + {machine_id=501,constraints="tags=compute,asrock03",base="ubuntu@22.04"}, + {machine_id=502,constraints="tags=compute,asrock04",base="ubuntu@22.04"}, +] + +infra-machines = [ + "asrock01", + "asrock02", + "asrock03", + "asrock04", +] + osd-devices = "/dev/sdb /dev/sdc" nagios-context = "arif-nc01"