ceph-installer/terraform/ceph-vm.tf

92 lines
2.0 KiB
HCL

### 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" = {
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/*"]
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" = {
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/*"]
environment = {
"PUB_KEY" = file("../data/ceph_key.pub")
"PRIV_KEY" = file("../data/ceph_key")
}
}
}
}