ibm-spectrum-scale-install-infra
ibm-spectrum-scale-install-infra copied to clipboard
[WARNING]: flush_handlers task does not support when conditional
Running the sample playbooks produces the following warning message:
[WARNING]: flush_handlers task does not support when conditional
This is because tasks in many of the roles are imported in the following way:
# example: roles/callhome/node/tasks/main.yml:
- import_tasks: install.yml
tags: install
when: scale_callhome_params is defined and scale_callhome_params.is_enabled|bool
This construct can be found in the following roles/files:
- roles/callhome/*/tasks/main.yml
- roles/gui/cluster/tasks/main.yml
- roles/nfs/*/tasks/main.yml
- roles/scale_ece/cluster/tasks/main.yml
- roles/scale_fileauditlogging/*/tasks/main.yml
- roles/smb/*/tasks/main.yml
With this conditional import (import_* and when) the meta: flush_handlers task doesn't work as expected. There is a detailled description of this in the following Ansible issue: meta: flush_handlers doesn't honor when clause (#41313). It doesn't look like the behavior is to be changed any time soon...
Hence, I see two options for getting rid of this warning:
-
Either we would need to change the way tasks are imported from
main.yml. Do we really need a separate switch for each role? If users import the role then what's the point of having them define an additional variable to actually enable the provided functionality? See #14 for further thoughts on this topic. -
Alternatively, we will need to scan the code and replace all
meta: flush_handlerstasks in these roles. We would need to copy the (relevant) code provided by the handlers and add the respective conditionals ourselves (i.e.register: variableand run the task onlywhen: variable.changed|bool). Furthermore, we would need to ensure that future contributions don't re-introducemeta: flush_handlers(linting).
Any thoughts?
Since https://github.com/ansible/ansible/issues/41313 was closed (unfairly IMHO), I reopened it as https://github.com/ansible/ansible/issues/77616.