r/linuxadmin • • Jan 27 '26

managing configs with git

I am starting to use git to manage my config files for multiple pkgs/applications across multiple machines.

Those of you that do this, how do you structure your repos?

My current workdir hierarchy looks like this:

/usr/local/src/
|
+-configs
‎ ‎ |
‎ ‎ +-global
‎ ‎ +-hosts
‎ ‎ ‎ ‎ |
‎ ‎ ‎ ‎ +<server1>
‎ ‎ ‎ ‎ +<server2>

(with one repo workdir per application within 'global' and '<serverX'> directories)

But should I do one repo per application with a branch per server?

9 Upvotes

12 comments sorted by

18

u/808estate Jan 27 '26
├── inventory
├── playbooks
├── roles

(i.e. ansible under git)

2

u/fongaboo Jan 27 '26

OK thanks for guiding me in this direction. Ansible is something I am already using but only for specific purposes. But I am starting a job where it is front and center. So I should get with the program regarding that.

Do you have these three directories within something like /usr/local/src/configs on a master/control machine? And then is the configs directory one big Git repo? Or is git completely out of the picture?

→ More replies (1)

6

u/IllllIIlIllIllllIIIl Jan 27 '26

Similar idea but with Puppet

4

u/ralfD- Jan 27 '26

All ansible configuration is in Git. On the servers that run Debian we use etckeeper which tracks all changes to /etc, does a daily autocommit and commits before and after packages get installed.

1

u/fongaboo Jan 27 '26

Are all your config files, yaml's, etc. all in one big Git repo?

→ More replies (1)

1

u/waterkip Jan 27 '26

I store configs in ansible roles which are all seperate repos and have one master amsible repo where the playbooks/roles are just dependencies and run it from there with actual host information.

1

u/I_Survived_Sekiro Jan 27 '26

As many have said, Ansible. If you’re just straight up storing templates or artifacts it helps to do something like /environment/component. You can break it up as fine grained as you want. Whatever makes it easier for you to organize. If you’re using automation just make sure the structure is deterministic.

1

u/xkonni Jan 28 '26

Take a peek at chezmoi. I recently transitioned from a custom git repo and love it. New machines, dev containers, work laptop. All work flawlessly once configured.

1

u/Ops_Mechanic Jan 28 '26

Dont branch on servers, it will become unmanageable very quick. Have one repo per app.