ceph-installer/terraform/ceph-vm.tf

92 lines
2.0 KiB
Terraform
Raw Permalink Normal View History

2024-01-27 23:26:11 +03:00
### ceph-mon
resource "lxd_instance" "ceph-mon" {
name = format("ceph-mon-%d", count.index + 1)
count = 4
type = "virtual-machine"
image = "ubuntu:jammy"
project = lxd_project.cephproject.name
profiles = ["default", "${lxd_profile.cephprofile.name}"]
config = {
"boot.autostart" = false
}
device {
name = "eth0"
type = "nic"
properties = {
nictype = "bridged"
parent = "${lxd_network.cephnet.name}"
"ipv4.address" = format("10.99.99.%d", count.index + 10)
}
}
limits = {
cpu = 2
memory = "4GiB"
}
execs = {
"shell_cmd" = {
2024-01-27 23:51:51 +03:00
command = ["/bin/sh", "-c", "sleep 10 ; echo $PUB_KEY | tee /root/.ssh/id_ed25519.pub /root/.ssh/authorized_keys ; echo \"$PRIV_KEY\" > /root/.ssh/id_ed25519 ; chmod 600 /root/.ssh/*"]
2024-01-27 23:26:11 +03:00
environment = {
"PUB_KEY" = file("../data/ceph_key.pub")
"PRIV_KEY" = file("../data/ceph_key")
}
}
}
}
### ceph-osd
resource "lxd_instance" "ceph-osd" {
name = format("ceph-osd-%d", count.index + 1)
count = 4
type = "virtual-machine"
image = "ubuntu:jammy"
project = lxd_project.cephproject.name
profiles = ["default", "${lxd_profile.cephprofile.name}"]
config = {
"boot.autostart" = false
}
device {
name = "eth0"
type = "nic"
properties = {
nictype = "bridged"
parent = "${lxd_network.cephnet.name}"
"ipv4.address" = format("10.99.99.%d", count.index + 20)
}
}
device {
name = format("ceph-osd-%d", count.index + 1)
type = "disk"
properties = {
source = format("ceph-osd-%d", count.index + 1)
pool = "default"
}
}
limits = {
cpu = 2
memory = "4GiB"
}
execs = {
"shell_cmd" = {
2024-01-27 23:51:51 +03:00
command = ["/bin/sh", "-c", "sleep 10 ; echo $PUB_KEY | tee /root/.ssh/id_ed25519.pub /root/.ssh/authorized_keys ; echo -e $PRIV_KEY > /root/.ssh/id_ed25519 ; chmod 600 /root/.ssh/*"]
2024-01-27 23:26:11 +03:00
environment = {
"PUB_KEY" = file("../data/ceph_key.pub")
"PRIV_KEY" = file("../data/ceph_key")
}
}
}
}