Skip to content

[WARNING]: flush_handlers task does not support when conditional #251

Open
@acch

Description

@acch

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 Single role to call that will call other roles in the playbook, to ensure consistency #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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions