Ansible Tower scheduled jobs use template extra vars?

1.6k views Asked by At

Do scheduled jobs in Tower use the extra vars set in the original template the job was based on?

Scheduled Jobs have extra vars also, but it seems like you'd want to still utilize the extra vars set in the template, and I'd rather not have to duplicate them. A change would require a change in the template and a change in every related scheduled job. It seems like extra vars could be set in a scheduled job, and it would have precedence over any variable in the template.

2

There are 2 answers

0
Carson Cole On BEST ANSWER

Tower does use the extra vars set in an underlying template. And if any Extra Vars are set in a Scheduled Job, they will take precedence. This behavior is what you would expect, now that I've used it a bit.

0
freginold On

According to the Ansible Job Templates documentation, the answer appears to be yes, unless they are overridden:

Prompt for Extra Variables: If this is checked, the user is prompted for Extra Variables at job execution. The set of extra variables defaults to any Extra Variables already configured for the job template.

Also from the same document:

... passing extra variables to a job template (as you would do with a survey) can override other variables being passed from the inventory and project.

And from the Variables documentation:

Inside a template you automatically have access to all of the variables that are in scope for a host.

So if you don't prompt for user-specified variables, or otherwise override the extra vars already set, Ansible will use any extra variables that are currently set.