Skip to content

Instantly share code, notes, and snippets.

@meh

meh/postgres.nix Secret

Created August 18, 2020 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meh/80585aa3c7e0077e9cd0ca499ec870f0 to your computer and use it in GitHub Desktop.
Save meh/80585aa3c7e0077e9cd0ca499ec870f0 to your computer and use it in GitHub Desktop.
fileSystems = {
"/var/lib/postgresql" = {
device = "/dev/rbd0";
fsType = "xfs";
options = ["rw" "noauto" "x-systemd.automount"];
};
};
systemd.automounts = [{
where = "/var/lib/postgresql";
requiredBy = ["postgresql.service"];
requires = ["network-online.target" "rbd0.service"];
}];
systemd.services.rbd0 = {
description = "RADOS block device for PostgreSQL";
requires = ["network-online.target"];
conflicts = ["shutdown.target"];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
ExecStart = "${pkgs.ceph-client}/bin/rbd --user postgres map postgres/data";
ExecStop = "${pkgs.ceph-client}/bin/rbd unmap /dev/rbd0";
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment