6

What is the easiest VCS to use to track /etc with? What are the challenges in storing the etc directory in version control, best practices? Should I use a centralized or distributed VCS?

Kyle Burton
  • 226
  • 2
  • 6
  • This could get religious, although sysadmins might not care much about this developer nonsense! This also might be better suited for stackoverflow. – tomjedrz May 27 '09 at 16:43
  • Seems to duplicate http://serverfault.com/questions/5410/using-revision-control-for-server-configuration-files and http://serverfault.com/questions/3852/what-tool-do-you-recommend-to-track-changes-on-a-linux-unix-server – Zoredache May 27 '09 at 16:46

7 Answers7

12

You could use etckeeper to handle it, which would let you use git, mercurial, darcs, or bzr for the repository.

Gene Gotimer
  • 2,442
  • 20
  • 16
6

Use etckeeper to do it for you. There's lot of reasons for this:

  • You will forget to use VCS on occasion; etckeeper hooks into package managers, giving you a pre-inst and post-inst state to roll back to
  • You will screw up file permissions
  • You will screw up handling the shadow passwd file
jldugger
  • 14,122
  • 19
  • 73
  • 129
4

I find git to be best at this job (although Mercurial would probably work just as well). A simple 'git init' in /etc, and you're on you're way. After that, just add the files you care about, and then any time they change, you can check it in. You can even set up cron to automatically do a checkin every time there is a change (although then you don't get log files). You can also push the repo around if you want to set a second machine that has all the same configs as the first, or just as a backup.

When I started sysadmining, rcs was the method of choice for /etc. Then came CVS, then SVN. I suspect when something new comes around, I'll switch to that. :) But with every new paradigm in VCS, my life has in fact gotten easier.

jedberg
  • 2,291
  • 22
  • 21
2

I agree with jedberg, however do the inverse. Use a git repository but create a .gitignore ignoring all files, then add an unignore for the files you care about. At least this way your git status isn't continually dirty.

ie: .gitignore * !hosts !resolv.conf

etc...

John

2

Without any religious intentions: I can highly recommend using a distributed VCS, preferably Bazaar. This is because:

  • Bazaar is easy to install (on Ubuntu and Debian servers it's just a matter of apt-get install bzr)
  • It's easy to setup and get started:
cd /etc
bzr init .
bzr add .
bzr commit . -m "Initial configuration"
  • No server setup required. Bazaar can connect and push to a remote repository without any remote Bazaar server running. Will work great with any FTP server or WEBDAV, etc.

Git and Mercurial are the other two contestants (as been pointed out in other answers) but they lack the ability to push to a remote server without setup (at least yet).

Anders Hansson
  • 179
  • 1
  • 4
2

I wouldn't manage all of /etc in a version control system. The reason is, most of the contents of /etc probably won't change much over time. Package management tools will manage a lot of files in /etc for you, and upgrading packages may cause interesting conflicts with a VCS.

Instead, I would use a configuration management system that manages various components and packages of my server(s), using templates and static files (where applicable) to configure the services and settings that store files in /etc (and elsewhere). I would store all that in a version control system, and I personally prefer Git, because as a system administrator, 'typical' Git workflows make more sense to me than Subversion (or CVS). Decentralization in Git makes it a huge win for system administration to me.

jtimberman
  • 7,511
  • 2
  • 33
  • 42
0

as an addition to all the advise here before (which all describe pretty much exactly what i do), i just discovered tig for myself. managing etc with git using cmdline was driving me crazy and changes were quickly piling up, without me showing any desire to take care of them. just randomly looking around for git GUIs i noticed there exists this ncurses-based one called tig.

now i'm actually looking forward to managing my /etc!

lkraav
  • 756
  • 1
  • 8
  • 21