ansible-redis icon indicating copy to clipboard operation
ansible-redis copied to clipboard

"flush_handlers task does not support when conditional"

Open thbar opened this issue 5 years ago • 4 comments

I have noticed this while upgrading to Ansible 2.7.12.

I am not sure yet what the implications are (e.g. is it already not flushing, when it should?).

TASK [DavidWittman.redis : add redis init config file] ***************************************************************************
ok: [the-machine]
[WARNING]: flush_handlers task does not support when conditional

thbar avatar Jul 29 '19 15:07 thbar

If I understand well, the relevant bits are around here. Please note that I don't use sentinel on this install, but there's probably the same pattern used there.

https://github.com/DavidWittman/ansible-redis/blob/9d00d7a73b775f6d42f6941e50c89dccfc4f878c/tasks/server.yml#L112-L131

thbar avatar Jul 29 '19 15:07 thbar

There is some input on the Ansible google group here, which seems to imply this has never worked (and failed silently before):

A when statement supplied to flush_handlers has never worked. It was silently ignored in the past, but now has a warning.

There is an open feature request to allow this to work: https://github.com/ansible/ansible/issues/41313

thbar avatar Jul 29 '19 15:07 thbar

A quick update - I updated the role to latest (thanks for your work!) and wanted to report this warning still appears. Not a huge deal for me, just wanted to either close the issue or update it.

thbar avatar May 19 '21 14:05 thbar

In order to resolve this, the flush_handlers action needs to be in a separate tasks file. Then, where flush_handlers is currently used, replace it with include_tasks leaving the when condition as is.

cognifloyd avatar Jul 19 '21 17:07 cognifloyd