ibm-spectrum-scale-install-infra icon indicating copy to clipboard operation
ibm-spectrum-scale-install-infra copied to clipboard

[WARNING]: flush_handlers task does not support when conditional

Open acch opened this issue 5 years ago • 1 comments

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:

  1. 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.

  2. Alternatively, we will need to scan the code and replace all meta: flush_handlers tasks in these roles. We would need to copy the (relevant) code provided by the handlers and add the respective conditionals ourselves (i.e. register: variable and run the task only when: variable.changed|bool). Furthermore, we would need to ensure that future contributions don't re-introduce meta: flush_handlers (linting).

Any thoughts?

acch avatar Oct 13 '20 07:10 acch

Since https://github.com/ansible/ansible/issues/41313 was closed (unfairly IMHO), I reopened it as https://github.com/ansible/ansible/issues/77616.

jmnavarrol avatar Apr 23 '22 11:04 jmnavarrol