# template functionality change between stable-1.9 and devel?

**URL:** <https://forum.ansible.com/t/template-functionality-change-between-stable-1-9-and-devel/19222>\
**Category:** Ansible Developer\
**Created:** [September 10, 2015, 7:53am UTC](https://forum.ansible.com/t/template-functionality-change-between-stable-1-9-and-devel/19222 "2015-09-10T07:53:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [September 10, 2015, 7:53am UTC](https://forum.ansible.com/t/template-functionality-change-between-stable-1-9-and-devel/19222/1 "2015-09-10T07:53:23Z")

</div>

- name: deploy /etc/nagios/nrpe\_local.cfg  
template: \>  
src=nrpe\_local\_cfg.j2  
dest=/etc/nagios/nrpe\_local.cfg  
owner=root  
group=root  
mode=0644

The above task works fine under the stable-1.9 branch but run under the devel branch

TASK [nagios-plugins : deploy /etc/nagios/nrpe\_local.cfg] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [dns\_servers]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “IOError: [Errno 2] No such file or directory: u’nrpe\_local\_cfg.j2’”}

$ ansible --version  
ansible 2.0.0 (devel 6de13c3062) last updated 2015/09/10 01:21:41 (GMT -500)  
lib/ansible/modules/core: (detached HEAD 34655e8e29) last updated 2015/09/09 20:58:51 (GMT -500)  
lib/ansible/modules/extras: (detached HEAD 6a3cf63351) last updated 2015/09/09 20:58:51 (GMT -500)  
config file =  
configured module search path = None

I did not open an official because I wondering if the functionality changed and I have a 1.9 task that needs to change to work with 2.0

All the following runs fail with “IOError: [Errno 2] No such file or directory:”

- name: deploy /etc/nagios/nrpe\_local.cfg  
template: \>  
src=templates/nrpe\_local\_cfg.j2  
dest=/etc/nagios/nrpe\_local.cfg  
owner=root  
group=root  
mode=0644  
tags: nagios-plugins

- name: deploy /etc/nagios/nrpe\_local.cfg  
template: \>  
src=~/projects/ansible.git/playbooks.git/roles/nagios-plugins/templates/nrpe\_local\_cfg.j2  
dest=/etc/nagios/nrpe\_local.cfg  
owner=root  
group=root  
mode=0644  
tags: nagios-plugins

These all work as expected

- name: deploy /etc/nagios/nrpe\_local.cfg  
template: \>  
src=…/playbooks.git/roles/nagios-plugins/templates/nrpe\_local\_cfg.j2  
dest=/etc/nagios/nrpe\_local.cfg  
owner=root  
group=root  
mode=0644  
tags: nagios-plugins

- name: deploy /etc/nagios/nrpe\_local.cfg  
template: \>  
src=/Volumes/Warrior1TB/Users/tanner/projects/ansible.git/playbooks.git/roles/nagios-plugins/templates/nrpe\_local\_cfg.j2  
dest=/etc/nagios/nrpe\_local.cfg  
owner=root  
group=root  
mode=0644  
tags: nagios-plugins

---

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [September 10, 2015, 8:56am UTC](https://forum.ansible.com/t/template-functionality-change-between-stable-1-9-and-devel/19222/2 "2015-09-10T08:56:24Z")

</div>

lib/ansible/plugins/action/template.py

Super hackery, but his let me task run. Hack is on line 71. Setting self.\_task.\_task\_include = None allows the code to fall through line 94 and the relative path of the template is built and loaded.

if faf:  
source = self.\_get\_first\_available\_file(faf, task\_vars.get(‘\_original\_file’, None, ‘templates’))  
if source is None:  
return dict(failed=True, msg=“could not find src in first\_available\_file list”)  
else:  
self.\_task.\_task\_include = None # Super hackery!  
if self.\_task.\_task\_include is not None:

Just guessing that load.path\_dwim\_relative() is the code I want to execute when using a relative template src path and they only way I can see it getting down to that code is if self.\_task.\_task\_include = None

---

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [September 10, 2015, 9:18am UTC](https://forum.ansible.com/t/template-functionality-change-between-stable-1-9-and-devel/19222/3 "2015-09-10T09:18:05Z")

</div>

Something else weird going on.

├── nagios-plugins  
│ ├── README.md  
│ ├── defaults  
│ │ └── main.yml  
│ ├── handlers  
│ │ └── main.yml  
│ ├── meta  
│ │ └── main.yml  
│ ├── tasks  
│ │ ├── debian.yml  
│ │ └── main.yml  
│ ├── templates  
│ │ └── nrpe\_local\_cfg.j2  
│ └── vars  
│ └── main.yml

tasks/main.yml

---

<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:** [September 10, 2015, 2:18pm UTC](https://forum.ansible.com/t/template-functionality-change-between-stable-1-9-and-devel/19222/4 "2015-09-10T14:18:54Z")

</div>

so it seems to be an issue of it not detecting it is in a role when  
processing non main.yml files included from the main.yml?
