In one my plays, a task executes a script that parses a file and exracts some credentials and saves them to a yaml file. If I try to access the variables in the file using vars_files it doesn’t work as I guess ansible tries to figure out the values of the variables even before any of the tasks are executed. Since the tasks that sets up the yaml file isn’t executed, ansible complains that the variable file isn’t present. Even if try a task that writes the credentials to /etc/ansible/facts.d in json and try accessing them, ansible complains that the the ansible_local variable isn’t present. Any workaround for this?
vars_files executes in the 'playbook compile phase' if you want to
dynamically load vars use include_vars module.