Linux Labs

Automation: Git and Ansible / Stage 1 of 6

The history of configuration changes

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 6 · on a machine · 5 min

nginx did not come up after an edit

What you will learn

  • Find an uncommitted config edit with git status and git diff and throw it away with git restore.
  • Find out from git log and git blame who changed a config line, when and in which commit.
  • Undo a bad commit with git revert so that the history and later edits stay in place.

Last night a colleague edited the lab-site site on the server and restarted nginx. In the morning the site does not answer: nginx is down. The nginx configuration is kept in git — the /etc/nginx directory keeps a history of edits. Check what nginx complains about and ask git what has changed.

Exercise · look

See what nginx complains about

In /etc/nginx test the nginx configuration, then ask git which files have changed.

First, predict

nginx did not come up after the edit. What will the configuration test sudo nginx -t print?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

git status called conf.d/lab-site.conf modified. What did git compare the file with?

  • There is no lab-site.conf in the package — a colleague created it. git can compare only with its own snapshots in .git.

  • git knows nothing about the running nginx — it looks only into the .git directory. Besides, nginx is down and has no loaded config.

  • Modification time does not decide it: git compares content. A file saved with no changes is not reported as modified by git status.

git status compares the working files with the last commit — a snapshot kept in .git.

Ubuntu 24.04
Loading…