# Regarding file changes in Ansible

**URL:** <https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586>\
**Category:** Ansible Project\
**Created:** [November 16, 2023, 1:47pm UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586 "2023-11-16T13:47:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [November 16, 2023, 1:47pm UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586/1 "2023-11-16T13:47:26Z")

</div>

Hi,

I have been trying to implement the following:

If any file change in git lab repo, then only we need to deploy the file in servers.

How to write Ansible playbook?

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [November 16, 2023, 2:03pm UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586/2 "2023-11-16T14:03:53Z")

</div>

that is very little information…

answers to these would help:

- what is in that gitlab repository?
- what is “the file”
- what are “servers”
- what does your inventory look like?

etc etc

---

<div class="post-metadata">

**Author:** ![Evan\_Hisey](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@Evan\_Hisey](https://forum.ansible.com/u/Evan_Hisey)\
**Post date:** [November 16, 2023, 4:09pm UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586/3 "2023-11-16T16:09:48Z")

</div>

Honestly sounds less like an ansible task and more like a git action or git runner job. Ansible natively has no idea what is in the git repo.

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [November 16, 2023, 7:05pm UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586/4 "2023-11-16T19:05:12Z")

</div>

I agree. This is a version control system action. That action could run an ansible playbook to push the changed file to an inventory of systems.

Walter

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [November 17, 2023, 12:29am UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586/5 "2023-11-17T00:29:32Z")

</div>

Hi ,

Please find the following:

> that is very little information…
> 
> answers to these would help:
> 
> - what is in that gitlab repository? configuration files, which are required to access our application
> - what is “the file”: like EAxI config file, jboss standalone file
> - what are “servers”:RHEL servers
> - what does your inventory look like?: SIT, UAT envs

Each environment has two servers

> etc etc

Please let me know if you need any other information.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [November 17, 2023, 3:59am UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586/6 "2023-11-17T03:59:49Z")

</div>

Ashok,

As a gitlab and Ansible user, this sounds to me like more of a gitlab problem than an Ansible problem.

You should follow and read the first few links at the top of [Gitlab CI Keyword Reference](https://gitlab.freedesktop.org/help/ci/yaml/index.md) index document. They should give you some ideas about how to make things happen when commits are made to your projects.

Good luck,

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [November 17, 2023, 5:10am UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586/7 "2023-11-17T05:10:37Z")

</div>

Hi Todd,

Thanks for providing your suggestion.

But, There are a few of the templates, which are available in gitlab. If there is any change in the template file, then only to deploy in UAT servers.  
This is what i am trying to implement. Is this not possible to implement in Ansible side?

Note: i did R&D and it suggested to implement synchronize module in ansible

---

<div class="post-metadata">

**Author:** ![mahespth](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mahespth/32/252_2.png) [@mahespth](https://forum.ansible.com/u/mahespth)\
**Post date:** [November 17, 2023, 10:32am UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586/8 "2023-11-17T10:32:37Z")

</div>

Hi Ashok

What you need is some sort of orchestrator or you can use gitlab CI and runner to execute ansible / ansible-navigator / ansible-runner etc etc . Another option that I have implemented in the past for customers is using ansible-pull from the ansible controller and execute plays accordingly. Hopefully some ideas you might be able to explore.

[https://www.ansible.com/blog/using-ansible-automation-platform-gitlab-ce-and-webhooks-to-deploy-iis-website](https://www.ansible.com/blog/using-ansible-automation-platform-gitlab-ce-and-webhooks-to-deploy-iis-website)

[https://www.devopsschool.com/blog/what-is-ansible-pull-and-how-can-we-use-it/](https://www.devopsschool.com/blog/what-is-ansible-pull-and-how-can-we-use-it/)

Regards

---

<div class="post-metadata">

**Author:** ![Ashok-2017](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ashok-2017/32/659_2.png) [@Ashok-2017](https://forum.ansible.com/u/Ashok-2017)\
**Post date:** [November 17, 2023, 11:34am UTC](https://forum.ansible.com/t/regarding-file-changes-in-ansible/38586/9 "2023-11-17T11:34:38Z")

</div>

Thanks Stephen. Let me take a look.
