Giter Club home page Giter Club logo

ansible-role-sanoid's Introduction

Ansible role exterrestris.sanoid

An Ansible role to install and configure automated ZFS snapshots and replication using Sanoid/Syncoid

Requirements

  • Sanoid package available in distribution
  • systemd

In order for Syncoid to replicate to a remote host, you must ensure that SSH access via public key authentication is correctly set up for the relevant users

Role Variables

Installation

Variable Default Comments
sanoid_install_from "package" Install Sanoid from OS package or from GitHub

Install from source

Variable Default Comments
sanoid_source_github_url https://github.com/jimsalterjrs/sanoid GitHub repo to clone
sanoid_source_version latest Git branch, tag or commit to checkout. latest will select the most recent release
sanoid_source_download_dir /tmp/sanoid Directory to clone repo to
sanoid_source_install_dir /usr/local/sbin Directory to install binaries to
sanoid_source_remove_package yes Remove the OS package if installed

Configuration

Variable Default Comments
sanoid_datasets [] List of datasets to snapshot
sanoid_templates Example templates from sanoid.conf List of policy templates
syncoid_syncs [] List of datasets to replicate

sanoid_templates[]

Variable Default Comments
name Required Template name
setting "" Policy setting

All settings supported by Sanoid in templates are supported - see sanoid.conf and sanoid.defaults.conf for details Similarly, most Syncoid flags are configurable via syncoid_syncs.

sanoid_datasets[]

Variable Default Comments
name Required ZFS dataset to snapshot
templates Required Sanoid template(s) to use for policy
recursive "no" Include child datasets with this dataset
process_children_only "no" Do not include this dataset
overrides [] List of template settings to override

syncoid_syncs[]

Variable Default Comments
src Required Source ZFS dataset
src_host "" Source host
src_user "root" Source user. Ignored if src_host empty
dest Required Destination ZFS dataset
dest_host "" Destination host
dest_user "root" Destination user. Ignored if dest_host empty
recursive "no" Copy child datasets
force_delete "no" Remove destination datasets recursively

Syncoid systemd Settings

Variable Default Comments
syncoid_service_name "syncoid" systemd service name for Syncoid
syncoid_timer_frequency "daily" systemd service frequency for Syncoid
syncoid_use_ssh_key yes Use an SSH key to login to remote hosts
syncoid_generate_ssh_key yes Generate an SSH key for Syncoid to use
syncoid_generated_ssh_key id_syncoid Name of generated SSH key
syncoid_ssh_key /root/.ssh/{syncoid_generated_ssh_key|id_rsa} Path to SSH key for Syncoid to use
syncoid_ssh_key_install_remote yes Install specified SSH key on remote hosts. Requires remote hosts to be defined in inventory

Example

sanoid_templates:
  - name: production
    frequently: 0
    hourly: 36
    daily: 30
    monthly: 3
    yearly: 0
    autosnap: 'yes'
    auto prune: 'yes'
  - name: backup
    frequently: 0
    hourly: 30
    daily: 90
    monthly: 12
    yearly: 0
    autoprune: 'yes'
    autosnap: 'no'
  - name: ignore
    autoprune: 'no'
    autosnap: 'no'
    monitor: 'no'

sanoid_datasets:
  - name: zpoolname/dataset
    templates:
      - production
      - demo
    overrides:
      hourly: 12
      monthly: 1
  - name: zpoolname/parent
    templates: production
    recursive: 'yes'
    process_children_only: 'yes'
  - name: zpoolname/parent/child
    templates: demo
    overrides:
      hourly: 4

syncoid_syncs:
  - src: zpoolname/parent
    dest: zpoolname/parent-backup
    dest_host: remote
    recursive: yes
  - src: zpoolname/dataset
    dest: zpoolname/dataset-backup

ansible-role-sanoid's People

Contributors

aroberts avatar exterrestris avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

timvy almereyda

ansible-role-sanoid's Issues

Support insecure send

jimsalterjrs/sanoid#513 implements an insecure mode for syncoid which doesn't use SSH for transfers. This is useful when replicating to devices like a Raspberry Pi which doesn't support hardware AES and is therefore transfer speed is CPU limited.

Additional software (socat and busybox) is required on both ends for the transfer to work, along with firewall rules to allow traffic

Configuration file creation is not idempotent

When I run the role against a computer that already has configured the /etc/sanoid/sanoid.conf file, the role overwrites this file with the default template.

I guess this task should be changed in main.yaml from:

- name: generate sanoid config
  ansible.builtin.template:
    src: ../templates/sanoid.conf.j2
    dest: "{{ sanoid_conf }}"
    owner: root
    group: root
    mode: '0600'

to:

- name: generate sanoid config
  ansible.builtin.template:
    src: ../templates/sanoid.conf.j2
    dest: "{{ sanoid_conf }}"
    owner: root
    group: root
    mode: '0600'
    force: false

Generate SSH keys with the Ed25519 curve

Currently this role generates RSA keys for Syncoid to pull the contents.

OpenSSH 9.5 uses the Ed25519 curve by default. It is considered more secure than RSA keys, while being more convenient and easier to handle, due to their shorter length.

It is suggested to add (optional) ed25519 key generation in a first step and to make it the default later, when proven stable.

Allow building from source

Useful when a package is outdated or unavailable in repos. Current HEAD is significantly newer than latest release

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.