I have done further digging on this and come up with the following:
The template in question is actually used as part of a dictionary:
```
# Define the resource tags
# If not updated by the CI system, put a placeholder deploy tag which indicates local deployment
# ANSIBLE_CALLER_USERNAME environment variable is set using the Docker wrapper script
deploy_version: "locally deployed by {{ lookup('env', 'ANSIBLE_CALLER_USERNAME') }}"
resource_tags:
Platform: "{{ platform_name }}"
Stage: "{{ environment_type }}"
DeployTag: "{{ deploy_version }}"
```
If I print this out in a debug statement then the tags dictionary is correct and also resources are deployed using the correct tags data. The part that is failing is an assertion:
```
- name: Validate variables that need to be defined by calling role
assert:
that: "{{ item }} is defined"
msg: "Variable {{ item }} is not defined"
quiet: yes
with_items: "{{ required_vars | default ([]) }} "
```
In this example resource_tags is in a list of required_vars we want defining and its giving us the error at the point it tries to assert the variable exists.
Thanks.
Andrew.