# How to trigger ansible playbook taks automatically based on template changes.

**URL:** <https://forum.ansible.com/t/how-to-trigger-ansible-playbook-taks-automatically-based-on-template-changes/27778>\
**Category:** Ansible Project\
**Created:** [June 12, 2018, 1:14pm UTC](https://forum.ansible.com/t/how-to-trigger-ansible-playbook-taks-automatically-based-on-template-changes/27778 "2018-06-12T13:14:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atul\_Sharma](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Atul\_Sharma](https://forum.ansible.com/u/Atul_Sharma)\
**Post date:** [June 12, 2018, 1:14pm UTC](https://forum.ansible.com/t/how-to-trigger-ansible-playbook-taks-automatically-based-on-template-changes/27778/1 "2018-06-12T13:14:59Z")

</div>

Hello ,

I have daily task to build and deploy with ansible and we are looking for such configuration that in git repo something got change in template folder related playbook automatically trigger

Please suggest if anyone has idea on that.

Thanks in advance for help 🙂

Atul

---

<div class="post-metadata">

**Author:** ![Muhamed\_ElMorsy](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@Muhamed\_ElMorsy](https://forum.ansible.com/u/Muhamed_ElMorsy)\
**Post date:** [June 12, 2018, 3:31pm UTC](https://forum.ansible.com/t/how-to-trigger-ansible-playbook-taks-automatically-based-on-template-changes/27778/2 "2018-06-12T15:31:51Z")

</div>

You need to register the repo, then add you build dir and finally the deployment stage when changed. For example :

- name: clone repository  
git: [repo=git@bitbucket.org](mailto:repo=git@bitbucket.org):repo/repo.git  
dest={{ repo.dir }}  
accept\_hostkey=yes  
register: gitrepo

- name: build  
command: “{{ item }}”  
with\_items:

- update

- make  
when: gitrepo.changed

```auto

```

---

<div class="post-metadata">

**Author:** ![Atul\_Sharma](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Atul\_Sharma](https://forum.ansible.com/u/Atul_Sharma)\
**Post date:** [June 12, 2018, 3:38pm UTC](https://forum.ansible.com/t/how-to-trigger-ansible-playbook-taks-automatically-based-on-template-changes/27778/3 "2018-06-12T15:38:07Z")

</div>

Thanks Muhamed,

Also can we trigger specific task in play book if any thing change in template folder for any file under roles?

Atul,
