ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
811 stars 1.49k forks source link

ZFS change user quota returns error #5494

Open rbnhln opened 1 year ago

rbnhln commented 1 year ago

Summary

When I try to change the user quota in a ZFS dataset using ansible, the value is changed but ansible reports an error.

Ansible returns:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "zfsprop was not present after being successfully set: userquota@UID"}

But the destination system returns after:

$ zfs get userquota@UID POOL/DATASET
NAME                 PROPERTY              VALUE                 SOURCE
POOL/DATASET  userquota@UID     20G                      local

Issue Type

Bug Report

Component Name

plugins/modules/zfs.py

Ansible Version

$ ansible --version
ansible [core 2.13.5]
  config file = 
  configured module search path = ['/Users/USER/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/6.5.0/libexec/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/USER/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.10.8 (main, Oct 21 2022, 22:22:30) [Clang 14.0.0 (clang-1400.0.29.202)]
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# /Users/USER/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 5.8.0  

# /opt/homebrew/Cellar/ansible/6.5.0/libexec/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 5.7.0  

Configuration

$ ansible-config dump --only-changed
DEFAULT_HOST_LIST(/Users/USER/Documents/ansible/ansible.cfg) = ['/Users/USER/Documents/ansible/inventory.yaml']
DEFAULT_REMOTE_USER(/Users/USER/Documents/ansible/ansible.cfg) = root

OS / Environment

macOS 13.0

Steps to Reproduce

---
- name: ZFS userquota
  hosts: HOST
  remote_user: root

  tasks: 
  - name: Set new userquota for USER
    community.general.zfs:
      name: POOL/DATASET
      state: present
      extra_zfs_properties:
        userquota@UID: 20G

Expected Results

Do not show error message.

Actual Results

Value is successfully changed, but error message is shown.

fatal: [localhost]: FAILED! => {"changed": false, "msg": "zfsprop was not present after being successfully set: userquota@UID"}

Code of Conduct

ansibullbot commented 1 year ago

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 commented 1 year ago

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

rbnhln commented 1 year ago

!component=plugins/modules/zfs.py

ansibullbot commented 1 year ago

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 commented 1 year ago

cc @johanwiren click here for bot help

munnik commented 1 year ago

I had a similar issue

The task:

- name: "Create ZFS root filesystem"
  become: true
  community.general.zfs:
    name: "{{ zfs_root_filesystem }}"
    state: present
    extra_zfs_properties:
      atime: "off"

Worked without issues when the filesystem didn't exist on the host. But when I run the task again on the same host and the filesystem exists I get this error: fatal: [xxx.xxx.xxx.xxx]: FAILED! => {"changed": false, "msg": "zfsprop was not present after being successfully set: atime"}

Workaround:

- name: "Create ZFS root filesystem"
  become: true
  community.general.zfs:
    name: "{{ zfs_root_filesystem }}"
    state: present

- name: "Set ZFS property"
  become: true
  ansible.builtin.command: "zfs set atime=off {{ zfs_root_filesystem }}"
loop-evgeny commented 1 month ago

Also running into this (with "userquota" specifically) on Ansible 2.16.8. The workaround of running a zfs command works, but is a bit annoying, because it reports a "change" every time.