include when not work

Hi team,

I have something like this in my tasks file.

  • name: run post sync files
    include: “{{inventory_dir}}/…/tasks/post-sync-files.yml”
    when: POST_SYNC_FILE == ‘yes’

Even the value of POST_SYNC_FILE is ‘no’ it still include the yml file and run . Inside the yml file there are bunch of tasks whihc also use when as well but not using the above variables.

Not sure what is wrong with this?

Thanks

The 'when' is being applied to the included tasks so they should all
appear as skipped, before 2.0 there is no way to prevent the include
itself from happening.

I guess it is time to try version 2 then.

Thanks

the only effective difference is less output