Add juju initial bits, and increase multi instances

This commit is contained in:
Arif Ali 2023-10-27 18:18:20 +01:00
parent 5c13e4d5f6
commit e25ea09ed4
Signed by: arif
GPG Key ID: 369608FBA1353A70
10 changed files with 237 additions and 1 deletions

1
juju/home-maas/00-init.tf Symbolic link
View File

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

View File

@ -0,0 +1,10 @@
variable openstack-origin {
type = string
default = "distro"
}
variable osd-devices {
type = string
default = ""
}

View File

@ -0,0 +1,20 @@
resource "juju_model" "cpe-focal" {
name = "cpe-focal"
cloud {
name = "home-maas"
}
config = {
cloudinit-userdata = file("user-data.yaml")
apt-mirror = "http://192.168.1.12/archive.ubuntu.com/ubuntu"
lxd-snap-channel = "5.0/stable"
container-image-metadata-url = "http://192.168.1.12/lxd/"
container-image-stream = "released"
agent-metadata-url = "http://192.168.1.12/juju/tools/"
agent-stream = "released"
}
}

View File

@ -0,0 +1,9 @@
resource "juju_machine" "all_machines" {
for_each = {
for index, machine in var.machines:
machine.machine_id => machine
}
model = juju_model.cpe-focal.name
name = each.value.machine_id
constraints = each.value.constraints
}

124
juju/home-maas/05-ceph.tf Normal file
View File

@ -0,0 +1,124 @@
resource "juju_application" "ceph-osd" {
name = "ceph-osd"
model = juju_model.cpe-focal.name
charm {
name = "ceph-osd"
channel = "octopus/stable"
}
units = 8
#placement = "1000,1002,1003,1004,1005,1006,1007"
config = {
osd-devices = var.osd-devices
source = var.openstack-origin
autotune = "false"
aa-profile-mode = "complain"
bluestore = "true"
osd-encrypt = "true"
osd-encrypt-keymanager = "vault"
}
}
resource "juju_application" "ceph-mon" {
name = "ceph-mon"
model = juju_model.cpe-focal.name
charm {
name = "ceph-mon"
channel = "octopus/stable"
}
units = 3
config = {
expected-osd-count = 12
source = var.openstack-origin
monitor-count = 3
customize-failure-domain = true
}
}
resource "juju_application" "ceph-radosgw" {
name = "ceph-radosgw"
model = juju_model.cpe-focal.name
charm {
name = "ceph-radosgw"
channel = "octopus/stable"
}
units = 3
config = {
source: var.openstack-origin
vip = "10.0.1.224"
region = "RegionOne"
operator-roles = "Member,admin" # Contrail requires admin and not Admin
}
}
resource "juju_application" "hacluster-radosgw" {
name = "hacluster-radosgw"
model = juju_model.cpe-focal.name
charm {
name = "hacluster"
channel = "2.0.3/stable"
}
}
resource "juju_integration" "osd-mon" {
model = juju_model.cpe-focal.name
application {
name = juju_application.ceph-osd.name
endpoint = "mon"
}
application {
name = juju_application.ceph-mon.name
endpoint = "osd"
}
}
resource "juju_integration" "rgw-mon" {
model = juju_model.cpe-focal.name
application {
name = juju_application.ceph-radosgw.name
endpoint = "mon"
}
application {
name = juju_application.ceph-mon.name
endpoint = "radosgw"
}
}
resource "juju_integration" "rgw-ha" {
model = juju_model.cpe-focal.name
application {
name = juju_application.ceph-radosgw.name
endpoint = "ha"
}
application {
name = juju_application.hacluster-radosgw.name
endpoint = "ha"
}
}

View File

@ -0,0 +1,21 @@
machines = [
{machine_id=100,constraints="tags=control,asrock01"},
{machine_id=101,constraints="tags=control,asrock02"},
{machine_id=102,constraints="tags=control,asrock03"},
{machine_id=103,constraints="tags=control,asrock04 spaces=oam"},
{machine_id=104,constraints="tags=control,asrock02"},
{machine_id=105,constraints="tags=control,asrock01"}, # needs to be asrock03
{machine_id=400,constraints="tags=compute,asrock01"},
{machine_id=401,constraints="tags=compute,asrock02"},
{machine_id=402,constraints="tags=compute,asrock03"},
{machine_id=1000,constraints="tags=compute,asrock01"},
{machine_id=1001,constraints="tags=compute,asrock01"},
{machine_id=1002,constraints="tags=compute,asrock02"},
{machine_id=1003,constraints="tags=compute,asrock02"},
{machine_id=1004,constraints="tags=compute,asrock03"},
{machine_id=1005,constraints="tags=compute,asrock03"},
{machine_id=1006,constraints="tags=compute,asrock04"},
{machine_id=1007,constraints="tags=compute,asrock04"},
]
osd-devices = "/dev/sdb /dev/sdc"

View File

@ -0,0 +1,43 @@
apt:
primary:
- arches: [amd64]
uri: http://192.168.1.12/archive.ubuntu.com/ubuntu
write_files:
- owner: root:root
path: /root/99-post-juju.yaml
permissions: '0644'
content: |
network:
version: 2
ethernets:
ens3:
link-local: []
ens4:
link-local: []
ens5:
link-local: []
ens6:
link-local: []
ens7:
link-local: []
ens8:
link-local: []
ens9:
link-local: []
- owner: root:root
path: /etc/systemd/network/99-default.link
permissions: '0644'
content: |
[Link]
NamePolicy=keep kernel database onboard path slot
preruncmd:
- locale-gen en_GB.UTF-8; update-locale
- "systemd-detect-virt --container && rm -rf /root/99-post-juju.yaml"
- "systemd-detect-virt --container && sudo snap remove --purge lxd"
- "! systemd-detect-virt --container && mv /root/99-post-juju.yaml /etc/netplan/99-post-juju.yaml"
- "! systemd-detect-virt --container && sudo lxc profile set default security.nesting true"
- sudo netplan apply
- "! systemd-detect-virt --container && update-initramfs -u -k all"
snap:
commands:
"00": systemctl restart snapd

8
juju/init.tf Normal file
View File

@ -0,0 +1,8 @@
terraform {
required_providers {
juju = {
version = "~> 0.10.0"
source = "juju/juju"
}
}
}

View File

@ -8,7 +8,7 @@ data "openstack_images_image_v2" "bionic-raw" {
}
resource "openstack_compute_instance_v2" "test_servers" {
count = 3
count = 7
name = format("%s_%02d", "test_server", count.index+1)
flavor_id = data.openstack_compute_flavor_v2.m1_small.id
key_pair = "arif-key"