# Using git module with multiple repos and only running make when a particular repo changes.

**URL:** <https://forum.ansible.com/t/using-git-module-with-multiple-repos-and-only-running-make-when-a-particular-repo-changes/19022>\
**Category:** Ansible Project\
**Created:** [August 14, 2015, 5:43pm UTC](https://forum.ansible.com/t/using-git-module-with-multiple-repos-and-only-running-make-when-a-particular-repo-changes/19022 "2015-08-14T17:43:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rodney\_Lott](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@Rodney\_Lott](https://forum.ansible.com/u/Rodney_Lott)\
**Post date:** [August 14, 2015, 5:43pm UTC](https://forum.ansible.com/t/using-git-module-with-multiple-repos-and-only-running-make-when-a-particular-repo-changes/19022/1 "2015-08-14T17:43:10Z")

</div>

My ansible version:

etdev@rlotttrustystock101012240:~$ ansible --version  
ansible 1.9.2  
configured module search path = None

I am using a local connection (i.e. doing stuff on my local machine).

In my playbook, I have the following line that checks out additional code repos to build using the git module:

`

- name: Checkout src directories  
register: repos\_state  
git: repo={{ item.value.url }} dest={{ item.value.checkout\_dir }} version={{ item.value.revision }} force=true  
with\_dict: “{{ repos }}”  
`

The repos variable is defined something like this:

`repos: dcs: url: "http://supersecretrepo/dcsurl.git" revision: 283fa10 checkout_dir: "{{ srcdir }}/dcs" build_dir: "{{ srcdir }}/dcs" ecp: url: "http://supersecretrepo/ecpurl.git" revision: fad759e checkout_dir: "{{ srcdir }}/ecp" build_dir: "{{ srcdir }}/ecp" vue: url: "http://supersecretrepo/vueurl.git" revision: dc9acab checkout_dir: "{{ srcdir }}/vue/vue" build_dir: "{{ srcdir }}/vue"`

I have a task following this that builds stuff from these repositories:

`

- name: Build the software  
shell: nohup make deb \> /tmp/{{ item.key }}-build.txt chdir={{ item.value.build\_dir }}  
with\_dict: “{{ repos }}”  
when: repos\_state.changed  
`

So, when the variable repos\_state shows an overall change, then it will rebuild **ALL** the software locations.

What I would like to know is if there is a more fine grained way to do this. Let’s say that I update the revision for repo dcs. In this case, I want my build software to only build the one that has changed. I have tried to figure out how to do this but haven’t had much luck.

Does anyone have a suggestion about how I could do this? I tried “when: repos\_state[{{item.key}}].changed” but that didn’t work.

I’m still fairly new to Ansible so I apologize if my question is simple.

Thanks.

Rodney
