template functionality change between stable-1.9 and devel?

  • 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

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

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

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?