Templating of injected vars

Issue Type:

Bugfix Pull Request

Ansible Version:

1.7.1+

Environment:

Mac OSX 10.9, bug is not os specific.

Summary:
Only substitute templates in variables once the order of all injected variables has been decided.

If when calling an include file, one of the parameters of the include was overridden with a value passed in as an 'extra', this value was not being passed in correctly to the include call.

So based on comments by James for the previous pull request for this issue #8984, I took another look at what was going on here and it seems that the templates in variables are being resolved before all of the variables sets are combined into the the injected set. Moving the templating to a point where the full set has been gathered removes this issue, with existing and added tests passing. I will close the other pull request.

Steps To Reproduce:

The test_includes.yml integration test has been updated to illustrate the issue

Expected Results:

when running a playbook containing the following

include: myinclude.yml some_var='{{extra_var}}'

where some_var is set to 'default' in the group vars but -e some_var='overridden' in the ansible call. We would expect the include to see some_var as 'overridden'

Actual Results:

With the scenario above the some_var is not overridden as expected but remains 'default'