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

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 :slight_smile:

Atul

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:repo/repo.git
    dest={{ repo.dir }}
    accept_hostkey=yes
    register: gitrepo

  • name: build
    command: “{{ item }}”
    with_items:

  • update

  • make
    when: gitrepo.changed


Thanks Muhamed,

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

Atul,