Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"flush_handlers task does not support when conditional" #216

Open
thbar opened this issue Jul 29, 2019 · 4 comments
Open

"flush_handlers task does not support when conditional" #216

thbar opened this issue Jul 29, 2019 · 4 comments

Comments

@thbar
Copy link
Contributor

thbar commented Jul 29, 2019

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
Copy link
Contributor Author

thbar commented Jul 29, 2019

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.

- name: add redis init config file
template:
dest: /etc/sysconfig/{{ redis_service_name }}
src: redis.init.conf.j2
mode: 0600
when: ansible_os_family == "RedHat"
notify: "restart redis {{ redis_port }}"
- name: add redis init config file
template:
dest: /etc/default/{{ redis_service_name }}
src: redis.init.conf.j2
mode: 0600
when: ansible_os_family == "Debian"
notify: "restart redis {{ redis_port }}"
# Flush handlers before ensuring the service is started to prevent
# a start and then restart
- name: flush handlers to apply config changes
meta: flush_handlers

@thbar
Copy link
Contributor Author

thbar commented Jul 29, 2019

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:
ansible/ansible#41313

@thbar
Copy link
Contributor Author

thbar commented May 19, 2021

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.

@cognifloyd
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants