# Failed to template {{ variable\_name }}, recursive loop error

**URL:** <https://forum.ansible.com/t/failed-to-template-variable-name-recursive-loop-error/19771>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [November 15, 2015, 3:35pm UTC](https://forum.ansible.com/t/failed-to-template-variable-name-recursive-loop-error/19771 "2015-11-15T15:35:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_Wilkerson](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@Rob\_Wilkerson](https://forum.ansible.com/u/Rob_Wilkerson)\
**Post date:** [November 15, 2015, 3:35pm UTC](https://forum.ansible.com/t/failed-to-template-variable-name-recursive-loop-error/19771/1 "2015-11-15T15:35:30Z")

</div>

I have a playbook that runs 2 plays and then includes a playbook from another project. When calling the external playbook, it attempts to pass along a couple of variables so that the external playbook has the proper context. The playbook looks like this:

- name: Launch any new EC2 instances  
hosts: local  
gather\_facts: false  
roles:

- { role: ec2, server\_type: web, server\_type\_abbrev: web, when: “‘web’ in server\_types” }

- name: Configure new EC2 instances  
hosts: ec2\_instances  
become: yes  
become\_method: sudo  
gather\_facts: true  
roles:

- common/server-config/essentials

- common/server-config/github

- name: Deploy the Project  
include: “…/…/project/ansible/aws.yml target\_env={{ env }} aws\_region={{ aws\_region }}”

If I remove the `aws_region` variable from the playbook include, all is well. With it in, though:

[WARNING]: non fatal error while trying to template play variables: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: Failed to template {{ aws\_region }}: Failed to  
template {{ aws\_region }}: recursive loop detected in template string: {{  
aws\_region }}

What am I doing wrong here?

Thanks.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [November 15, 2015, 3:51pm UTC](https://forum.ansible.com/t/failed-to-template-variable-name-recursive-loop-error/19771/2 "2015-11-15T15:51:05Z")

</div>

It appears to be because you are setting a variable to itself:

aws\_region={{ aws\_region }}

Without trying it, you may just be able to omit providing that, because the variable is already defined as you want it.

Otherwise, you will have to change the name of one of those variables.

---

<div class="post-metadata">

**Author:** ![Rob\_Wilkerson](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@Rob\_Wilkerson](https://forum.ansible.com/u/Rob_Wilkerson)\
**Post date:** [November 15, 2015, 3:56pm UTC](https://forum.ansible.com/t/failed-to-template-variable-name-recursive-loop-error/19771/3 "2015-11-15T15:56:34Z")

</div>

I did try changing the variable name to “region”, e.g.

region={{ aws\_region }}

but that didn’t change anything. To improve my understanding…are you telling me that even when calling an external playbook, all variables created in the initial playbook are still in scope? I didn’t really even consider that since it’s, well, external. I’ll try that first.

Thanks, Matt.
