# git update

**URL:** <https://forum.ansible.com/t/git-update/28858>\
**Category:** Ansible Project\
**Created:** [October 24, 2018, 6:44am UTC](https://forum.ansible.com/t/git-update/28858 "2018-10-24T06:44:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [October 24, 2018, 6:44am UTC](https://forum.ansible.com/t/git-update/28858/1 "2018-10-24T06:44:50Z")

</div>

Hi All,

I have one use case where if the new user is created in the server then ansible playbook update the file /etc/passwd and /etc/shadow file in version control.

The ansible script check the difference and update the version control with the latest copy of both the file.

Looking forward for reply.

Regards  
Sumit Sahay  
7044112109

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [October 24, 2018, 11:45am UTC](https://forum.ansible.com/t/git-update/28858/2 "2018-10-24T11:45:55Z")

</div>

That just seems like bad practice. I wouldn’t recommend this.

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [October 26, 2018, 7:39am UTC](https://forum.ansible.com/t/git-update/28858/3 "2018-10-26T07:39:16Z")

</div>

Thanks Jonathan for your reply.  
But it is part of the use case, I am trying to achieve it.

Is there way to achieve it.

Regards  
Sumit Sahay  
7044112109

---

<div class="post-metadata">

**Author:** ![Brad2](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Brad2](https://forum.ansible.com/u/Brad2)\
**Post date:** [October 26, 2018, 10:48am UTC](https://forum.ansible.com/t/git-update/28858/4 "2018-10-26T10:48:19Z")

</div>

Not sure putting such information in some version control system is the wisest, but if you do have it under version control of some type, the version control mechanism should be able to tell if it has been updated. You would then just have to have ansible run the version control command to check if an update was made, then run the update if required.

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [October 29, 2018, 10:14am UTC](https://forum.ansible.com/t/git-update/28858/5 "2018-10-29T10:14:04Z")

</div>

Thanks Brad Van Orden for your reply.

Sorry I didn’t get, what are you trying to say.

Could you please explore it, so that I can resolve the issue.

---

<div class="post-metadata">

**Author:** ![Brad2](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Brad2](https://forum.ansible.com/u/Brad2)\
**Post date:** [October 29, 2018, 11:11am UTC](https://forum.ansible.com/t/git-update/28858/6 "2018-10-29T11:11:18Z")

</div>

What I meant is (this is assuming you have already designated /etc/password and /etc/shadow to be under git control),

run a command task with “git status” and register the output to a variable.  
In the next task, ( at least at first for testing purposes), run a debug task and print out the variable.  
See what it says for status of password/shadow. Then, in the following task, use another command task with git update as the command and a when statement based on the variable output only when it needs to get updated.

If git status output contains, “nothing to commit, working directory clean” then you have no updates to make. If on the other hand, you see “modified: shadow” or something like that, then you know you need to run git update.

Make a little more sense?
