I want to track random config files / directories from my server into git repository. I do not mean tracking the /etc, here are some examples:


and so on...

since git does not follow symlinks, I can mount with bind, e.g.

mount /etc/named /REPO/etc-named -obind
mount /var/named /REPO/var-named -obind

I don't like this approach because it will do mount for each directory, but at least this is safe and will works correctly.

for files, I can do hard links, but I do not like the idea very much, because I can "lost" the link easily if I do something like:

mv /etc/named.conf /etc/named.conf.old
cp xxxxx /etc/named.conf

any suggestions how this can be sorted out?

  • Is there any reason you can't create a "configs" repo (or similar) and add the specific files/directories you want to this repo ? – Martin Feb 26 '15 at 7:45
  • 4
    Careful: you will lose meta information (permissions) and not be able to track empty folders which are important sometimes. Don't reinvent the wheel, check out github.com/joeyh/etckeeper (but unsure if it can track files outside of /etc). – faker Feb 26 '15 at 8:19
  • @Martin what is the alternative? Several repo's or all files in /etc ... – Nick Feb 26 '15 at 8:32
  • A single repo or 1 at the top of each hierarchy /etc or /var. Adding all of /etc will add lots of redundant data. @faker makes some good points though. – Martin Feb 26 '15 at 8:36

Don't do it this way.

Instead, use a config management system (Ansible, Saltstack, etc.). Keep those files in version control and use that the CM to deploy config changes to your servers.

Doing things this way is highly beneficial in many ways: you have a full, offline backup of your server configurations, you can easily apply this configuration to multiple servers or to test/dev servers, etc.

I know this likely isn't the answer you were hoping for, but by all accounts, it's the professional way to manage systems.

  • What? No Puppet? – ewwhite Feb 26 '15 at 13:44
  • 1
    @ewwhite Haha, nope. Puppet's on my blacklist. :) I haven't used it for several years so this may have changed, but I also feel that it is much easier to get up and running with Ansible, especially for simple projects and one-off systems like this. – EEAA Feb 26 '15 at 13:47
  • my goal is not automation and scalability, but sometimes we do changes to important files and later forget who changed what and when. – Nick Feb 26 '15 at 15:22
  • @Nick Exactly - this is a prime use case for using version-controlled configuration manifests. – EEAA Feb 26 '15 at 15:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.