I have a playbook which has the following content:
/home/username/project/deploybook.yml
- hosts: api_servers
tasks:
- import_tasks: roles/api/tasks/deploy.yml
And the task file deploy.yml imported by the plabook in the role "api" which is concerned with management of api servers:
/home/username/project/roles/api/tasks/deploy.yml
- name: copy api supervisor config to servers
template:
src: "{{ item }}"
dest: "/etc/supervisor/conf.d/{{ item|basename }}.conf"
force: yes
with_fileglob:
- "supervisor/*.*"
notify: restart supervisor
The above play fails because Ansible fails to locate the config files which residese in the role's template folder at:
/home/username/project/roles/api/templates/supervisor/gunicorn.j2
Ansible is searching for the templates folder within the tasks folder and not the templates directory located in the parent folder. How to solve this?