community.general
community.general copied to clipboard
filesystem is not idempotent when used with resizefs option
SUMMARY
After running filesystem twice with resizefs argument set to 'yes', the second time it fails with an error:
xfs_growfs: /dev/mapper/vgubuntu-testlv is not a mounted XFS filesystem\
due to not monted filesystem.
ISSUE TYPE
- Bug Report
COMPONENT NAME
filesystem
ANSIBLE VERSION
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/eferet/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
CONFIGURATION
No notable changes.
OS / ENVIRONMENT
Ubuntu
STEPS TO REPRODUCE
Minimal playbook to run on system with lvm and lv group named: 'vgubuntu'
- hosts: all
tasks:
- block:
lvol:
vg: vgubuntu
lv: "{{ lv_name }}"
size: '16'
- filesystem:
dev: /dev/mapper/vgubuntu-{{ lv_name }}
resizefs: yes
fstype: xfs
loop: [0,1]
become: yes
vars:
lv_name: testlv
EXPECTED RESULTS
changed: [x] => {"changed": false}
ACTUAL RESULTS
failed: [x] (item=1) => {"ansible_loop_var": "item", "changed": false, "cmd": "/usr/sbin/xfs_growfs -n /dev/mapper/vgubuntu-testlv", "item": 1, "msg": "xfs_growfs: /dev/mapper/vgubuntu-testlv is not a mounted XFS filesystem", "rc": 1, "stderr": "xfs_growfs: /dev/mapper/vgubuntu-testlv is not a mounted XFS filesystem\n", "stderr_lines": ["xfs_growfs: /dev/mapper/vgubuntu-testlv is not a mounted XFS filesystem"], "stdout": "", "stdout_lines": []}
Files identified in the description:
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
cc @abulimov @pilou- @quidame click here for bot help
I also stumbled upon this issue, which is made worse by the fact that the returned dictionary structure is completely different to when the module succeeds, which makes error handling very difficult. First, the module could detect that no size change is necessary, but, even if it can't, the returned dictionary should have the same structure, so that one can rely on the same keys being defined (e.g. to easily handle with failed_when
or ignore_errors
).
@eferet , thanks for reporting this issue.
Currently, not all systems are able to access unmounted xfs filesystems to get size info. Some can, and I've submitted a PR to at least support these ones. This makes that your testcase is passing (the filesystem task in loop reports a changed state the first time, and no changes the next times), but only for GNU/Linux distros supporting xfs_info DEVICE
and not just xfs_info MOUNTPOINT
(it's not just about xfsprogs version, as far as I understand results of failed tests).
So, PR #1478 adds some bits of idempotency to the module, that still don't work for CentOS 6 & 7 and Ubuntu 16.04 & 18.04 and FreeBSD (any version).
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.