include_vars doesn't seem to persist across hosts

I’m required to

  • name: include consul secrets
    include_vars: /tmp/secrets.yml

for each set of -hosts:

Is it possible to include this file at the beginning and not have to call it for every host?

use vars_files at the play level, include_vars is designed to
specifically work as you describe.

Is it possible to have an ansible task that generates the /tmp/secrets.yml. The playbook fails because secrets.yml doesn’t exist until the first task is run.

you can use multiple plays

I run ansible-playbook from within a docker container so files that are created don’t persist across subsequent runs. I was able to create a includes_vars task under hosts: all which fixes the issue for me.

Thanks!