[WARNING]: flush_handlers task does not support when conditional

198 views
Skip to first unread message

tendo...@gmail.com

unread,
Jun 12, 2019, 11:47:28 AM6/12/19
to Ansible Project
I have really simple role, in which I have these tasks:

---

- name: Download the app artifact from s3 bucket
  aws_s3
:
    bucket
: "my-bucket"
   
object: "/my-artifact.tar.gz"
    mode
: get
    dest
: "my-artifact.tar.gz"
  notify
:
   
- Restart App


- name: Unarchive the tar file
  unarchive
:
    src
: "my-artifact.tar.gz"
    dest
: "/app-dir"




- name: Copy the templates to desired locations
 
template:
    src
:  "my-app.j2"
    dest
: "/app-dir/my-app.config"
  notify
:
   
- Restart App


- meta: flush_handlers


- Some other tasks


Here is my simple handler:
---
- name: Restart App
  systemd
:
    name
: "my-app"
    state
: restarted


but at the meta step I am getting this warning:

[WARNING]: flush_handlers task does not support when conditional

It was working fine until, 2.5.x but getting this warning after upgrading to 2.7/2.8, I didn't have any when condition.

any help will be highly appreciated 

Dick Visser

unread,
Jun 14, 2019, 12:25:35 PM6/14/19
to ansible...@googlegroups.com
This appears to be fine, but as you say this is only the role.
This indicates that issue is elsewhere, for instance in the calling playbook.
Can you share that?
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d4bcf3db-18e2-4339-9475-c38cbc4b007d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

tendo...@gmail.com

unread,
Jun 16, 2019, 1:15:20 PM6/16/19
to Ansible Project
my main.yml is really simply like this:

---
- import_tasks: git.yml
 
when: GIT_ENABLED | default(false)
- import_tasks: -s3.yml
 
when: not (GIT_ENABLED | default(false))

Matt Martz

unread,
Jun 17, 2019, 10:17:14 AM6/17/19
to ansible...@googlegroups.com
When using `import_tasks`, ansible will read the file, and effectively replace your `import_tasks` with the tasks that are inside it.  When we do that, the `when` statement gets added to each individual task within.  

As such, you get this warning.

Switching to `include_tasks` should avoid this.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages