Failed to template {{ variable_name }}, recursive loop error

980 views
Skip to first unread message

Rob Wilkerson

unread,
Nov 15, 2015, 10:35:30 AM11/15/15
to Ansible Project
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.

Matt Martz

unread,
Nov 15, 2015, 10:51:09 AM11/15/15
to ansible...@googlegroups.com
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.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f71f69f9-70e9-4709-bb9d-3e9bbc75e1fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

Rob Wilkerson

unread,
Nov 15, 2015, 10:56:34 AM11/15/15
to Ansible Project
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.
Reply all
Reply to author
Forward
0 new messages