# template not expanded after upgrading from 1.7 to 2.0.1.0

**URL:** <https://forum.ansible.com/t/template-not-expanded-after-upgrading-from-1-7-to-2-0-1-0/21127>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [April 11, 2016, 9:22am UTC](https://forum.ansible.com/t/template-not-expanded-after-upgrading-from-1-7-to-2-0-1-0/21127 "2016-04-11T09:22:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![seb.stark](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@seb.stark](https://forum.ansible.com/u/seb.stark)\
**Post date:** [April 11, 2016, 9:22am UTC](https://forum.ansible.com/t/template-not-expanded-after-upgrading-from-1-7-to-2-0-1-0/21127/1 "2016-04-11T09:22:11Z")

</div>

I am sure I missed something here, but couldn’t find a hint in the changelog. So far I used ansible 1.7 on Ubuntu 12.04.5 and recently upgraded to ansible 2.0.1.0 on ubuntu 16.04 (beta) and it worked well. Only one of my playbooks is causing problems.

The template in question sits in a sub directory called check\_mk, and I call it like this:

`ansible-playbook check_mk/gen_check_mk_config.yml`

It gathers facts from all my servers and compiles a single configuration file to be put on some host. This works exactly like intended with my older ansible 1.7 installation, but not with my 2.0.1.0 installation on ubuntu 16.04 (beta). There is no error message, it just won’t expand the template but rather copy the generic jinja2 template, unexpanded, to the destination.

This is the playbook:

`  
$ cat check\_mk/gen\_check\_mk\_config.yml

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [April 11, 2016, 7:35pm UTC](https://forum.ansible.com/t/template-not-expanded-after-upgrading-from-1-7-to-2-0-1-0/21127/2 "2016-04-11T19:35:18Z")

</div>

Does calling the playbook with

ansible-playbook -vvv check\_mk/...

return any more info what goes wrong?

Johannes

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 12, 2016, 4:07am UTC](https://forum.ansible.com/t/template-not-expanded-after-upgrading-from-1-7-to-2-0-1-0/21127/3 "2016-04-12T04:07:46Z")

</div>

hostvars is not a dict anymore, so .keys() might not work

---

<div class="post-metadata">

**Author:** ![seb.stark](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@seb.stark](https://forum.ansible.com/u/seb.stark)\
**Post date:** [April 12, 2016, 6:07am UTC](https://forum.ansible.com/t/template-not-expanded-after-upgrading-from-1-7-to-2-0-1-0/21127/4 "2016-04-12T06:07:03Z")

</div>

The output is a bit long so I’m hesitating to post it here. But in my eyes it looks no different from the output of a working playbook execution. In particular there is no error message. Thank you anyway.

---

<div class="post-metadata">

**Author:** ![seb.stark](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@seb.stark](https://forum.ansible.com/u/seb.stark)\
**Post date:** [April 12, 2016, 6:11am UTC](https://forum.ansible.com/t/template-not-expanded-after-upgrading-from-1-7-to-2-0-1-0/21127/5 "2016-04-12T06:11:47Z")

</div>

That’s it! Thank you so much. If I replace hostvars.keys() with groups[‘servers’] it works!

Using unsupported ways to access internal data structures (.keys()) should be avoided, I know, but still I wonder why ansible does not indicate a failed template expansion and simply pushes the jinja2 code, which in almost any case should be the wrong thing to do and lead to service failure.
