Skip to content

A NixOS module to run a Pacemaker cluster using pcs.

License

Notifications You must be signed in to change notification settings

matt1432/nixos-pcsd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NixOS pcsd

This is a Nix flake containing the package pcs and a module for it that allows you to manage a Pacemaker cluster declaratively in nix code.

Docs

You can read about the options this module exposes here: https://matt1432.github.io/nixos-pcsd/all/

Usage

In your flake.nix inputs:

...
pcsd = {
  # This way of declaring inputs is way cleaner IMO
  type = "github";
  owner = "matt1432";
  repo = "nixos-pcsd";

  # Here is the classic one
  # url = "github:matt1432/nixos-pcsd";
};
...

Before enabling this module, it is very important to know that it will manage services.pacemaker and services.corosync for you. Any of their settings could be replaced by the ones you declare in services.pcsd.

In your server config, this would be the most barebones settings:

{pcsd, ...}: {
  imports = [pcsd.nixosModules.default];

  services.pcsd = {
    enable = true;
    enableBinaryCache = true;

    # I highly recommend using sops-nix or agenix for these settings
    corosyncKeyFile = builtins.toFile "keyfile" "some128charLongText";
    clusterUserPasswordFile = builtins.toFile "password" "somePassword";

    nodes = [
      {
        name = "this Machine's Hostname";
        nodeid = 1;
        ring_addrs = [
          # This is where your machine's local ips go
          "192.168.0.255"
        ];
      }

      # the other nodes of your cluster go here
    ];
  };
}

You can also take a look at my pcsd setup to see more options and a real world example.

Credits

About

A NixOS module to run a Pacemaker cluster using pcs.

Resources

License

Stars

Watchers

Forks