Sysadmins should pretty much version control everything

December 20, 2012

Today's Sysadvent contained a casual, matter of fact bit:

This code [for deployment scripts] has probably never been threatened with version control.

I had a reaction to this.

At work, we are not quite hep to all the current DevOps coolness. We don't have metrics and dashboards, we don't have everything automated with things like Puppet, Chef, or Cfengine, and so on. But even in our low state of evolution, we do version control pretty much everything that moves. Our almost invariable rule is that anything that we change gets put in version control first. Scripts, configurations, etc etc.

Here is the thing. Doing this is trivial. You don't need to start up some big version control infrastructure or system to keep /etc in a big repository, you don't have to decide between git and Mercurial, and you barely need to do anything extra.

Just use RCS. RCS is a trivially easy single-file version control system. You don't have to set up anything big or make any particular changes in how you work. All you need to do (after a quick initial setup) is to run one more command after you edit something and are satisfied with your work (commit messages are optional but useful). And for doing that, you get all of the usual version control goodness; you can see what changed and when, and you can revert back to a past version (or pull bits of it out). Since RCS operates on single files, you can use it selectively, in mixed and tangled directories like /etc, and only when you need it.

By the way, don't worry that using RCS instead of something more sophisticated will prove a terrible decision in the future. You can migrate from RCS to other things when you reach that point.

(My writeup was for Mercurial, but you can use CVS-to-git stuff to move to git too.)

Sidebar: what it takes to use RCS the easy sysadmin way

apt-get install rcs
mkdir RCS
ci -l <file>
rcs -U <file>
[edit]
ci -u <file>
[edit]
ci -u <file>

There. You're done. Repeat the last two steps every time you edit the file (really, the last step, since you're already editing the file).

(Obviously some of the the initial steps can be skipped after the first time or the first time in any particular directory.)


Comments on this page:

From 129.102.5.21 at 2012-12-20 04:27:38:

Things are even easier if you use emacs: just hit "C-x v v" and emacs will version control the file in the current buffer, using RCS by default and creating the RCS directory if it is not already here. It's basically an automatic behavior for me.

-- Arnaud Gomes

From 70.40.44.173 at 2012-12-20 06:10:16:

If you write script to do the checkout, edit and check in, it works nicely too.

From 132.183.156.105 at 2012-12-20 10:38:49:

There is a program called rcsedit which is useful to automate some of the steps. You still need to understand the rcs commands, at least a little bit, for some cases, but for the majority of my files, it works just fine. I use the version from the FreeBSD ports system, but I think there are a number of different implementations that all do basically the same thing.

From 69.164.167.126 at 2012-12-20 12:01:38:

Most certainly good in principal. To fit in this model, everything would be file based, and we all know that for many platforms, that is just not possible. I also find athat sometimes it can fall short in providing context to a change. Good living documentation (wiki, OneNote, etc.) makes up for the area that strict version control cannot; providing the reader with some understanding on context, and "why."

It is my position that most organization can benefit most from a good wiki (or something to that affect), then introduce opportunities for file based version control at a later date.

By cks at 2012-12-21 10:00:07:

I stronlg disagree with the view that living documentation is a higher priority than version control; I feel that version control is much more important. I wrote more on this in VersionControlFirst.

Written on 20 December 2012.
« Part of good awk programming is getting the clause order right
Version control comes first »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Thu Dec 20 03:14:15 2012
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.