community.general icon indicating copy to clipboard operation
community.general copied to clipboard

community.general.zfs tries to reset volblocksize thus breaking idempotency

Open rbadass opened this issue 3 years ago • 11 comments

Summary

When running the following: community.general.zfs: name: pool/vol1 state: present extra_zfs_properties: volsize: 4G volblocksize: 4k

the initial run succeeds and creates the zvol, however subsequent runs fail with: FAILED! => {"changed": false, "msg": "cannot set property for 'pool/vol1': 'volblocksize' is readonly\n"}

it should simply skip over and not try to set volblocksize as it's already at the correct volblocksize.

Issue Type

Bug Report

Component Name

zfs

Ansible Version

ansible [core 2.12.3]

Community.general Version

community.general 1.3.0
community.general 4.6.0

Configuration

$ ansible-config dump --only-changed

OS / Environment

No response

Steps to Reproduce

community.general.zfs: name: pool/vol1 state: present extra_zfs_properties: volsize: 4G volblocksize: 4k

Expected Results

I expected it to skip over a property that was already set correctly.

Actual Results

It tried to re-set the volblocksize property, which is readonly and thus throws an error.

Code of Conduct

  • [X] I agree to follow the Ansible Code of Conduct

rbadass avatar May 19 '22 00:05 rbadass

Files identified in the description:

  • plugins/modules/packaging/os/pkg5

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar May 19 '22 00:05 ansibullbot

cc @bcoca @fishman @jasperla @jpdasma @mator @mavit @scathatheworm @troy2914 @xen0l click here for bot help

ansibullbot avatar May 19 '22 00:05 ansibullbot

!component =plugins/modules/storage/zfs/zfs.py

felixfontein avatar May 19 '22 05:05 felixfontein

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar May 19 '22 05:05 ansibullbot

cc @johanwiren click here for bot help

ansibullbot avatar May 19 '22 05:05 ansibullbot

This should have been fixed in #1833. Are you sure you tried this also with community.general 4.6.0, and not just with community.general 1.3.0 (which is EOL btw)?

felixfontein avatar May 19 '22 05:05 felixfontein

This should have been fixed in #1833. Are you sure you tried this also with community.general 4.6.0, and not just with community.general 1.3.0 (which is EOL btw)?

i just updated and tried again, the problem persists

$ ansible-galaxy collection list community.general community.general 4.8.1

rbadass avatar May 19 '22 07:05 rbadass

When I change volblocksize = 4k to vloblocksize = 4096, task become "ok". I don't know why volsize = 4G is good but volblocksize = 4k is not.

cola-zero avatar Jan 29 '23 13:01 cola-zero

Same thing with the encryption property:

The following can only one once, every other time it errors:

- name: create encrypted guest zfs volume
  community.general.zfs:
    name: "{{ zfs_encrypted_guest_dataset }}"
    state: present
    extra_zfs_properties:
      encryption: on
      keyformat: hex
      keylocation: file:///root/.rpool-data-encrypted.key
      compression: zstd-3
TASK [rmblr.proxmox_setup : create encrypted guest zfs volume ] ********************
fatal: [mill]: FAILED! => changed=false 
  cmd: /usr/sbin/zfs set encryption=on rpool/data/encrypted
  msg: 'cannot set property for ''rpool/data/encrypted'': ''encryption'' is readonly'
  rc: 1
  stderr: |-
    cannot set property for 'rpool/data/encrypted': 'encryption' is readonly
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

Using community.general==6.3.0

Analysis

Looking at the code, the module is parsing the result of essentially this (filtered down to the encryption property):

$ zfs get -H -p -o property,value,source all rpool/data/encrypted|grep encryption
encryption	aes-256-gcm	-
encryptionroot	rpool/data/encrypted	-

Note that the playbook called for encryption=on. In modern ZFS (2.1.9) this is equivalent to aes-256-gcm in previous versions the default encryption value was different.

Changing the playbook to use encryption: aes-256-gcm makes it idempotent.

Ramblurr avatar Feb 27 '23 14:02 Ramblurr

Hello!

Any plans on fixing this issue?

Tualua avatar Sep 27 '24 09:09 Tualua

I'm not aware of anyone working on this.

felixfontein avatar Sep 27 '24 09:09 felixfontein

Changing the playbook to use encryption: aes-256-gcm makes it idempotent.

@Ramblurr this is an oldie, but just wanted to share that you saved my bacon with this one. Thanks!

awfulwoman avatar Dec 18 '25 21:12 awfulwoman