git update

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

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

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

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.

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.

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?