Bug Report: LVM role conditional evaluates to string instead of boolean
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- Jinja
- Stars
- 1.4k
- Forks
- 379
- Avg merge
- 4d 18h
- Merged PRs (30d)
- 8
Description
**Bug Report: LVM role conditional evaluates to string instead of boolean**
**File:** `ansible/roles/lvm/tasks/manage_lvm.yml`
**Line:** 10
**Problem:**
The `when` condition in the "Rescan LVM Volume Groups" task:
```yaml
when: ((lvm__register_devices_filter | d() and lvm__register_devices_filter is changed) or
(lvm__register_devices_global_filter | d() and lvm__register_devices_global_filter is changed))
Can fail with:
Conditional result (False) was derived from value of type 'str'
Root Cause:
When lvm__register_devices_filter is undefined, | d() returns an empty string.
The expression lvm__register_devices_filter | d() and ... evaluates to a string,
not a boolean.
Suggested Fix:
when: ((lvm__register_devices_filter is defined and lvm__register_devices_filter.changed) or
(lvm__register_devices_global_filter is defined and lvm__register_devices_global_filter.changed))
Workaround:
Users can pre-define these variables in host_vars:
lvm__register_devices_filter:
changed: false
lvm__register_devices_global_filter:
changed: false
Environment:
- DebOps version: 3.3.0
- Ansible core: 2.21.2
- Python: 3.12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ansible/roles/lvm/tasks/manage_lvm.yml line 10 and inspect the "Rescan LVM Volume Groups" task and its when condition. Reproduce the case with the LVM filter variables undefined, then verify that the condition evaluates as a boolean and that the task behaves correctly without the host_vars workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ansible
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100