From c8a79e890c7495f2df800f0290f59ebe73ae86b8 Mon Sep 17 00:00:00 2001 From: mg Date: Thu, 16 Dec 2021 19:49:33 +0100 Subject: [PATCH] =?UTF-8?q?zfs=5Fdatasets:=20Unterst=C3=BCtzt=20jetzt=20al?= =?UTF-8?q?le=20Parameter=20(#284)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michael Grote Reviewed-on: https://git.mgrote.net/mg/ansible/pulls/284 Co-authored-by: mg Co-committed-by: mg --- roles/mgrote.zfs_manage_datasets/README.md | 50 ++++++-------- .../mgrote.zfs_manage_datasets/tasks/main.yml | 67 ++++++++++++++----- 2 files changed, 71 insertions(+), 46 deletions(-) diff --git a/roles/mgrote.zfs_manage_datasets/README.md b/roles/mgrote.zfs_manage_datasets/README.md index 1daa5e5c..de3ab986 100644 --- a/roles/mgrote.zfs_manage_datasets/README.md +++ b/roles/mgrote.zfs_manage_datasets/README.md @@ -1,37 +1,27 @@ ## mgrote.zfs_manage_datasets -### Beschreibung -Erstellt Datasets/setzt Optionen pro Dataset. -Kann Datasets löschen. -Die Pools müssen vorher existieren. -Beim ersten ausführen wird es wahrscheinlich zu Status: "changed" kommen, weil: -```bash -ssd_vm_mirror/vm xattr sa inherited from ssd_vm_mirror -ssd_vm_mirror/vm xattr sa local -``` -Die Attribute werden nicht mehr vererbt sondern als "local" gesetzt +### Description +Creates Datasets, can set options. +This role does not create the pools. +Attributes get set `local` per dataset. -### getestet auf + +### tested on - [x] ProxMox 6.1 +- [x] ProxMox 7* ### Variablen + Defaults -#### Standardwerte -``` -state: present -compression: lz4 -sync: standard -xattr: on -dnodesize: auto -atime: off -snapdir: hidden -``` -#### Empfohlen für VMs -``` -state: present -compression: lz4 -sync: disabled -xattr: sa -dnodesize: auto -atime: off -snapdir: hidden +- see [default-filter](./tasks/main.yml) +- all Variables from `man 8 zfs` are optional but not the name(dataset) + +#### Example +```yaml + zfs_datasets: + - dataset: rpool/vm + state: present + compression: zstd + - dataset: tank/vm/dir/fileserver2_test + state: present + atime: on + snapdir: hidden ``` diff --git a/roles/mgrote.zfs_manage_datasets/tasks/main.yml b/roles/mgrote.zfs_manage_datasets/tasks/main.yml index 9bb5bd63..d56d179c 100644 --- a/roles/mgrote.zfs_manage_datasets/tasks/main.yml +++ b/roles/mgrote.zfs_manage_datasets/tasks/main.yml @@ -1,24 +1,59 @@ --- - - name: create datasets - become: true - community.general.zfs: - name: "{{ item.dataset }}" - state: "{{ item.state | default('present') }}" - loop: "{{ zfs_datasets }}" - when: zfs_datasets is defined # führe nur aus wenn die Variable gesetzt ist - - - name: set zfs properties per datasets + - name: create datasets or set options become: true community.general.zfs: name: "{{ item.dataset }}" state: "{{ item.state | default('present') }}" extra_zfs_properties: - compression: "{{ item.compression | default('lz4') }}" - sync: "{{ item.sync | default('standard') }}" - xattr: "{{ item.xattr | default('on') }}" - dnodesize: "{{ item.dnodesize | default('auto') }}" - atime: "{{ item.atime | default('off') }}" - snapdir: "{{ item.snapdir | default('hidden') }}" - recordsize: "{{ item.recordsize | default('128K') }}" + quota: "{{ item.quota | default(omit) }}" + reservation: "{{ item.reservation | default(omit) }}" + recordsize: "{{ item.recordsize | default(omit) }}" + mountpoint: "{{ item.mountpoint | default(omit) }}" + sharenfs: "{{ item.sharenfs | default(omit) }}" + checksum: "{{ item.checksum | default(omit) }}" + compression: "{{ item.compression | default(omit) }}" + atime: "{{ item.atime | default(omit) }}" + devices: "{{ item.devices | default(omit) }}" + exec: "{{ item.exec | default(omit) }}" + setuid: "{{ item.setuid | default(omit) }}" + readonly: "{{ item.readonly | default(omit) }}" + zoned: "{{ item.zoned | default(omit) }}" + snapdir: "{{ item.snapdir | default(omit) }}" + aclmode: "{{ item.aclmode | default(omit) }}" + aclinherit: "{{ item.aclinherit | default(omit) }}" + canmount: "{{ item.canmount | default(omit) }}" + xattr: "{{ item.xattr | default(omit) }}" + copies: "{{ item.copies | default(omit) }}" + vscan: "{{ item.vscan | default(omit) }}" + nbmand: "{{ item.nbmand | default(omit) }}" + sharesmb: "{{ item.sharesmb | default(omit) }}" + refquota: "{{ item.refquota | default(omit) }}" + refreservation: "{{ item.refreservation | default(omit) }}" + primarycache: "{{ item.primarycache | default(omit) }}" + secondarycache: "{{ item.secondarycache | default(omit) }}" + logbias: "{{ item.logbias | default(omit) }}" + dedup: "{{ item.dedup | default(omit) }}" + mlslabel: "{{ item.mlslabel | default(omit) }}" + sync: "{{ item.sync | default(omit) }}" + dnodesize: "{{ item.dnodesize | default(omit) }}" + volmode: "{{ item.volmode | default(omit) }}" + filesystem_limit: "{{ item.filesystem_limit | default(omit) }}" + snapshot_limit: "{{ item.snapshot_limit | default(omit) }}" + filesystem_count: "{{ item.filesystem_count | default(omit) }}" + snapshot_count: "{{ item.snapshot_count | default(omit) }}" + snapdev: "{{ item.snapdev | default(omit) }}" + acltype: "{{ item.acltype | default(omit) }}" + context: "{{ item.context | default(omit) }}" + fscontext: "{{ item.fscontext | default(omit) }}" + defcontext: "{{ item.defcontext | default(omit) }}" + rootcontext: "{{ item.rootcontext | default(omit) }}" + relatime: "{{ item.relatime | default(omit) }}" + redundant_metadata: "{{ item.redundant_metadata | default(omit) }}" + overlay: "{{ item.overlay | default(omit) }}" + encryption: "{{ item.encryption | default(omit) }}" + keylocation: "{{ item.keylocation | default(omit) }}" + keyformat: "{{ item.keyformat | default(omit) }}" + pbkdf2iters: "{{ item.pbkdf2iters | default(omit) }}" + special_small_blocks: "{{ item.special_small_blocks | default(omit) }}" loop: "{{ zfs_datasets }}" when: zfs_datasets is defined # führe nur aus wenn die Variable gesetzt ist