ZFS Replication with Ansible
Mark Elvers
~1 min read

Categories

  • openzfs

Tags

  • tunbury.org

Rather than using the agent-based approach proposed yesterday, it’s worth considering an Ansible-based solution instead.

Given a set of YAML files on a one-per-dataset basis containing any metadata we would like for administrative purposes, and with required fields such as those below. We can also override any default snapshot and replication frequencies by adding those parameters to the file.

dataset_path: "tank/dataset-02"
source_host: "x86-bm-c1.sw.ocaml.org"
target_host: "x86-bm-c3.sw.ocaml.org”

The YAML files would be aggregated to create an overall picture of which datasets must be replicated between hosts. Ansible templates would then generate the necessary configuration files for synoid and sanoid, and register the cron jobs on each machine.

Sanoid uses SSH authentication, so the keys must be generated on the source machines, and the public keys must be deployed on the replication targets. Ansible can be used to manage the configuration of the keys.

Given the overall picture, we can automatically generate a markdown document describing the current setup and use Mermaid to include a visual representation.

I have published a working version of this concept on GitHub. The README.md contains additional information.

The replication set defined in the repository, ZFS Replication Topology, is currently running for testing.