Size: 2419
Comment:
|
← Revision 6 as of 2013-05-30 18:09:18 ⇥
Size: 2781
Comment: automated install ensures this is always installed, note config packages
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
[[http://kitenet.net/~joey/code/etckeeper/|Etckeeper]] puts /etc under revision control, git | [[http://kitenet.net/~joey/code/etckeeper/|Etckeeper]] puts `/etc` under revision control, git |
Line 4: | Line 4: |
All our machines use EtcKeeper, which should be installed early in the setup process. (Typically among the first packages installed after performing the system installation and first boot). |
All our machines use EtcKeeper, which is installed automatically as part of the AutomatedSystemInstall. |
Line 17: | Line 16: |
== Usage == | == Git commands == |
Line 19: | Line 18: |
The most useful Git commands we most often use are: | The most useful Git commands are: |
Line 24: | Line 23: |
git log -p (see commits with diff included) | git log -p [FILE] (see commits with diff included) |
Line 26: | Line 25: |
git diff (see any differences since last commit) git commit -am "Commit message" (commit your changes after modification) git checkout FILE (override FILE with version from last commit) |
git diff [FILE] (see any differences since last commit) git commit FILE... (commit FILE after modification) git checkout FILE... (override FILE with version from last commit) |
Line 31: | Line 30: |
Each time you make a change to a file or set of files and are happy with it, commit your change. | == EtcKeeper usage == Each time you make a change to a file or set of files and are happy with it, commit your change. If you are editing something in `/etc/`, you should probably be modifying or creating a [[ConfigurationManagement|config package]]. |
Line 35: | Line 36: |
The -a switch very often commits other changed files that had nothing to do with your commit, such as modified by not committed changes of other admins or files automatically generated/modified by DomTool or system scripts. Those automatically-modified files should be handled in one of the following ways, in order of preference from highest to lowest: | The reason for this is: the -a switch very often commits other changed files that had nothing to do with your commit, such as modified but not committed changes from other admins, or files automatically generated/modified by DomTool or system scripts. |
Line 37: | Line 38: |
* If they change often (such as hosts.deny/hosts.allow), move them to /var/tmp/ and provide a symlink from /etc/, registering only the symlink in Git. * Periodically committing them (just them) with the appropriate commit message (i.e. "Periodic commit of modified files") * Removing them from Git (copy them aside, invoke '''git rm FILE; git commit -am "Remove FILE"''', and copy them back to expected location |
Those automatically-modified files should be handled in one of the following ways, in order of preference from highest to lowest: |
Line 41: | Line 40: |
== Notes == | 1. If they change often (such as hosts.deny/hosts.allow), move them to /var/tmp/ (or other suitable location) and provide a symlink from /etc/, registering only the symlink in Git. 2. Periodically commit them (just them) with the appropriate commit message (i.e. "Periodic commit of modified files") 3. Remove them from Git (copy them aside, invoke '''git rm FILE; git commit -am "Remove FILE"''', and copy them back to expected location |
Line 43: | Line 44: |
EtcKeeper is better than custom solutions as it also adds apt hooks, so the files are added and commited to git automatically before/after apt-get installs. |
=== Notes === EtcKeeper Debian package comes bundled with APT hooks which automatically invoke git commit -a before and after apt-get installs. This is handy, but this way of pre-apt committing is lame. If there's anything to commit, do it manually. And generally if anything gets committed during the automatic run, it should be just files from category (2) above. ---- CategorySystemAdministration CategoryNeedsWork |
Etckeeper puts /etc under revision control, git by default, which then behaves like a normal git repository.
All our machines use EtcKeeper, which is installed automatically as part of the AutomatedSystemInstall.
1. Installation
apt-get install etckeeper etckeeper init cd /etc git commit -am "Initial commit"
2. Git commands
The most useful Git commands are:
git status (list of files and their Git states) git log (see commit dates & commit msgs) git log -p [FILE] (see commits with diff included) git add FILE... (add FILE to git) git diff [FILE] (see any differences since last commit) git commit FILE... (commit FILE after modification) git checkout FILE... (override FILE with version from last commit)
3. EtcKeeper usage
Each time you make a change to a file or set of files and are happy with it, commit your change. If you are editing something in /etc/, you should probably be modifying or creating a config package.
It is tempting to use git commit -am "Message ..." which commits all files (-a) and provide the commit message on the command line (-m "..."). While that is tolerable practice, listing specific files on the command line and providing a properly formatted Git commit message is preferred over the "bulk" -am switches.
The reason for this is: the -a switch very often commits other changed files that had nothing to do with your commit, such as modified but not committed changes from other admins, or files automatically generated/modified by DomTool or system scripts.
Those automatically-modified files should be handled in one of the following ways, in order of preference from highest to lowest:
- If they change often (such as hosts.deny/hosts.allow), move them to /var/tmp/ (or other suitable location) and provide a symlink from /etc/, registering only the symlink in Git.
- Periodically commit them (just them) with the appropriate commit message (i.e. "Periodic commit of modified files")
Remove them from Git (copy them aside, invoke git rm FILE; git commit -am "Remove FILE", and copy them back to expected location
3.1. Notes
EtcKeeper Debian package comes bundled with APT hooks which automatically invoke git commit -a before and after apt-get installs.
This is handy, but this way of pre-apt committing is lame. If there's anything to commit, do it manually. And generally if anything gets committed during the automatic run, it should be just files from category (2) above.