{"id":24863702,"url":"https://github.com/stuvusit/zfs-storage","last_synced_at":"2025-10-15T09:31:37.883Z","repository":{"id":46971549,"uuid":"86482205","full_name":"stuvusIT/zfs-storage","owner":"stuvusIT","description":"Ansible role to configure zfs-on-linux zvols and filesystems that can be shared via NFS","archived":false,"fork":false,"pushed_at":"2021-09-19T21:56:11.000Z","size":67,"stargazers_count":6,"open_issues_count":6,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-12-15T04:38:35.577Z","etag":null,"topics":["ansible","debian","nfs","role","storage","ubuntu","vm","yml","zfs"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc-by-sa-4.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stuvusIT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-28T16:22:55.000Z","updated_at":"2023-12-15T04:38:35.578Z","dependencies_parsed_at":"2022-08-30T08:30:44.241Z","dependency_job_id":null,"html_url":"https://github.com/stuvusIT/zfs-storage","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuvusIT%2Fzfs-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuvusIT%2Fzfs-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuvusIT%2Fzfs-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuvusIT%2Fzfs-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stuvusIT","download_url":"https://codeload.github.com/stuvusIT/zfs-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236600149,"owners_count":19175167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","debian","nfs","role","storage","ubuntu","vm","yml","zfs"],"created_at":"2025-01-31T23:33:22.346Z","updated_at":"2025-10-15T09:31:37.579Z","avatar_url":"https://github.com/stuvusIT.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zfs-storage\n\nThis role installs ZFS on Linux and configures filesystems and ZVOLs.\n`nfs-kernel-server` will be installed if a configured filesystem makes use of the `sharenfs` attribute.\nNFS exports will be permanently configured in `/etc/exports.d/zfs-storage-ansible.exports` if `zfs_save_nfs_exports` is set accordingly.\nThe [ZFS PPAs from JonathanF](https://launchpad.net/~jonathonf) are used to install the latest ZFS release.\n\n## Requirements\n\nOne of the following distribution releases:\n- Debian stretch or buster\n- Ubuntu xenial, bionic, cosmic or devel\n\n`systemd` is required in order to scrub pools using timers instead of distribution-specific cron jobs.\n`python-jmespath` is needed on the machine executing this role to correctly determine the need for NFS.\n\n## Role Variables\n\n| Name                           | Default / Mandatory | Description                                                                                                                                                                                                                                                         |\n|:-------------------------------|:-------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `zfs_parent_fs`                |                     | Existing parent ZFS filesystem for all filesystems and zvols that is optionally prepended to all configurations                                                                                                                                                     |\n| `zfs_storage_defaults`         | `{}`                | Dict containing ZFS attributes that will be applied to all configured ZFS filesystems/zvols                                                                                                                                                                         |\n| `zfs_filesystems`              | `[]`                | List of zfs_filesystems defined by a `name` and a dict of `attributes` (mandatory for each entry)                                                                                                                                                                   |\n| `zfs_zpools`                   | `[]`                | List of dicts having a `name` (mandatory) and `scrub` (optional) key. `scrub` is a boolean and can disable scrubbing for this pool.                                                                                                                                 |\n| `zvols`                        | `[]`                | List of zvols defined by a `name` and a dict of `attributes` (mandatory for each entry)                                                                                                                                                                             |\n| `zfs_default_enable_scrub`     | `True`              | Whether to enable zpool scrubbing by default                                                                                                                                                                                                                        |\n| `zfs_scrub_frequency`          | `weekly`            | Frequency of zfs scrubbing - already running scrubs will be aborted. See [systemd.time](https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events) for allowed values.                                                                   |\n| `zfs_kernel_module_parameters` | `{}`                | Dict containing ZFS kernel module options to be set in `/etc/modprobe.d/zfs.conf`.                                                                                                                                                                                  |\n| `zfs_storage_drive_wwids`      | `[]`                | List of WWID strings of blockdevices in the pool. UDEV rules will be written to set the IO scheduler to `noop` for those devices. This is needed for partitioned or encrypted devices as ZFS only sets the scheduler to `noop` if it gets ahold of the whole drive. |\n| `zfs_save_nfs_exports`         | `True`              | Whether to save and delete (if not needed) a NFS export file for consistent exports across reboots.                                                                                                                                                                 |\n\nNote: There are some ZFS attributes that can only be set at creation (see [man zfs](https://linux.die.net/man/8/zfs)).\nThese are `utf8only`, `normalization` and `casesensitivity` for filesystems and `volsize` and `volblocksize` for ZVOLs.\nThe respective task will fail if you try to change those.\nAlso, `volsize` is a mandatory attribute for ZVOLs.\n\nIf an attribute is not defined, the ZFS default will be configured (even if the attribute is already set to something else), except for these four attributes:\n- `acltype`=`posixacl`\n- `compression`=`on`\n- `relatime`=`on`\n- `xattr`=`sa`\n\nAll default values for ZFS attributes can be seen in [the defaults](defaults/main.yml).\n\nIn addition to the actual ZFS attributes described in the [man page](https://linux.die.net/man/8/zfs), this role sets attributes to control automatic snapshotting using tools such as  [zfs-auto-snapshot](https://github.com/zfsonlinux/zfs-auto-snapshot).\nThis is achieved using the following variables, which are all set to `False` by default:\n\n| ZFS attribute                    | Variable name in this role       | Description                                                                                                                                                                                       |\n|:---------------------------------|:---------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `com.sun:auto-snapshot`          | `com_sun_auto_snapshot`          | Enable automatic snapshotting and cleaning (destroying) of snapshots using all available intervals for the current dataset (basically acts as if all the following attributes are set to `True`). |\n| `com.sun:auto-snapshot:frequent` | `com_sun_auto_snapshot_frequent` | Enable snapshotting and cleaning in 15min intervals.                                                                                                                                              |\n| `com.sun:auto-snapshot:hourly`   | `com_sun_auto_snapshot_hourly`   | Enable snapshotting and cleaning in hourly intervals.                                                                                                                                             |\n| `com.sun:auto-snapshot:daily`    | `com_sun_auto_snapshot_daily`    | Enable snapshotting and cleaning in daily intervals.                                                                                                                                              |\n| `com.sun:auto-snapshot:weekly`   | `com_sun_auto_snapshot_weekly`   | Enable snapshotting and cleaning in weekly intervals.                                                                                                                                             |\n| `com.sun:auto-snapshot:monthly`  | `com_sun_auto_snapshot_monthly`  | Enable snapshotting and cleaning in monthly intervals.                                                                                                                                            |\n\n\n\n## Example Playbook\n\n```yml\n- hosts: zfsstorage\n  roles:\n    - role: zfs-storage\n      zfs_parent_fs: tank\n      zfs_zpools:\n        - name: rpool\n          scrub: False\n        - name: tank\n          scrub: False\n      zfs_scrub_frequency: monthly\n      zfs_kernel_module_parameters:\n        zfs_arc_max: 30064771072 # Allow ARC to grow to 30GB\n      zfs_storage_defaults:\n        acltype: posixacl\n        volsize: 50G\n        quota: 50G\n      zfs_filesystems:\n        - name: testing\n          attributes:\n            quota: 200G\n        - name: testing/wiki\n          attributes:\n            sharenfs: rw=@172.27.10.13\n            compression: off\n      zvols:\n        - name: testing/dns01\n          attributes:\n            volsize: 100G\n        - name: testing/ldap01\n          attributes:\n```\n\n### Result\n\n| Name                  | Type       | Attributes                                                                              |\n|:----------------------|:-----------|:----------------------------------------------------------------------------------------|\n| `tank/testing`        | filesystem | `acltype`=`posixacl`, `quota`=`200G`                                                    |\n| `tank/testing/wiki`   | filesystem | `acltype`=`posixacl`, `sharenfs`=`rw=@172.27.10.13`, `compression`=`off`, `quota`=`50G` |\n| `tank/testing/dns01`  | zvol       | `volsize`=`100G`                                                                        |\n| `tank/testing/ldap01` | zvol       | `volsize`=`50G`                                                                         |\n\n`rpool` won't be scrubbed, `tank` will be scrubbed `monthly`.\n\n## License\n\nThis work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/).\n\n## Author Information\n\n- [Michel Weitbrecht (SlothOfAnarchy)](https://github.com/SlothOfAnarchy) _michel.weitbrecht@stuvus.uni-stuttgart.de_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuvusit%2Fzfs-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuvusit%2Fzfs-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuvusit%2Fzfs-storage/lists"}