Having some trouble with a callback, hoping somebody can help me out.
I’m trying to get information that the user has set in variables during the playbook_on_play_start method by calling task.module_vars.get(‘var_name_goes_here’). However, it looks like not all variables have been resolved at this point. The ones that were passed in on the command line are available, but ones that are set in other ways (i.e. in group vars or host vars) still have the uninterpolated value (i.e. “{{ var_name_goes_here }}”). Any advice?
This is expected, most of the templating happens as late as possible, so it is quite normal that if you have vars that show the ‘untemplated’ value and you won’t get them resolved until after the task is initialized and run.
I would need more information about your case before I can give you detailed advice.What you can try is to template the variables yourself by calling template (from ansible.utils.template import template).
Keep in mind that it might not be the exact same result as the template can rely on other variables that can be modified in the interim and you possibly don’t have the exact same data. Also, each task/host gets it’s own copy of the variables for customization and they don’t get reflected on the common copy.