Grab latest from live deployment with all fixes

* Upgrade provider to 0.19.0
* This means palcement is replaced by machines.
* Use virt-type for constraints to use LXD instead of kvm
* Add bundle for applications that don't deploy via TF
* Add infra model
* Add ldap app
* Fix microk8s model
This commit is contained in:
2025-06-23 15:35:34 +01:00
parent e3e4e464b5
commit 0b6dcbdee0
42 changed files with 580 additions and 368 deletions

23
juju/home-maas-jammy/.gitignore vendored Normal file
View File

@@ -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

View File

@@ -1,9 +1,8 @@
terraform {
required_providers {
juju = {
version = "~> 0.15.0"
version = "~> 0.19.0"
source = "juju/juju"
}
}
}

View File

@@ -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"

View File

@@ -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")
}

View File

@@ -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" {

View File

@@ -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

View File

@@ -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

View File

@@ -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" {

View File

@@ -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
},{

View File

@@ -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" {

View File

@@ -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"
}
}

View File

@@ -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" {

View File

@@ -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 = [{

View File

@@ -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" {

View File

@@ -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" {

View File

@@ -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"

View File

@@ -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" {

View File

@@ -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"

View File

@@ -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" {

View File

@@ -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" {

View File

@@ -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"
}
}

View File

@@ -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"
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -1 +0,0 @@
../../init.tf

View File

@@ -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"
}

View File

@@ -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"
}
}

View File

@@ -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"

View File

@@ -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

View File

@@ -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"
}
}

View File

@@ -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"
}

View File

@@ -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
]
}

View File

@@ -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"
}
}

View File

@@ -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"
}
}

View File

@@ -0,0 +1 @@
../00-init.tf

View File

@@ -0,0 +1 @@
../00-variables.tf

View File

@@ -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 = [{

View File

@@ -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"
}

View File

@@ -8,8 +8,6 @@ resource "juju_application" "ntp" {
channel = "latest/stable"
base = "ubuntu@22.04"
}
units = 0
}
resource "juju_integration" "ntp-k8s" {

View File

@@ -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"
}
}

View File

@@ -0,0 +1 @@
../terraform.tfvars

View File

@@ -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"