UbuntuWiki:VersionControlledEtc
文章出处: |
{{#if: | {{{2}}} | https://wiki.ubuntu.com/VersionControlledEtc }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/af | • {{#if: UbuntuWiki:VersionControlledEtc|Afrikaans| [[::UbuntuWiki:VersionControlledEtc/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/ar | • {{#if: UbuntuWiki:VersionControlledEtc|العربية| [[::UbuntuWiki:VersionControlledEtc/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/az | • {{#if: UbuntuWiki:VersionControlledEtc|azərbaycanca| [[::UbuntuWiki:VersionControlledEtc/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/bcc | • {{#if: UbuntuWiki:VersionControlledEtc|جهلسری بلوچی| [[::UbuntuWiki:VersionControlledEtc/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/bg | • {{#if: UbuntuWiki:VersionControlledEtc|български| [[::UbuntuWiki:VersionControlledEtc/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/br | • {{#if: UbuntuWiki:VersionControlledEtc|brezhoneg| [[::UbuntuWiki:VersionControlledEtc/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/ca | • {{#if: UbuntuWiki:VersionControlledEtc|català| [[::UbuntuWiki:VersionControlledEtc/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/cs | • {{#if: UbuntuWiki:VersionControlledEtc|čeština| [[::UbuntuWiki:VersionControlledEtc/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/de | • {{#if: UbuntuWiki:VersionControlledEtc|Deutsch| [[::UbuntuWiki:VersionControlledEtc/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/el | • {{#if: UbuntuWiki:VersionControlledEtc|Ελληνικά| [[::UbuntuWiki:VersionControlledEtc/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/es | • {{#if: UbuntuWiki:VersionControlledEtc|español| [[::UbuntuWiki:VersionControlledEtc/es|español]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/fa | • {{#if: UbuntuWiki:VersionControlledEtc|فارسی| [[::UbuntuWiki:VersionControlledEtc/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/fi | • {{#if: UbuntuWiki:VersionControlledEtc|suomi| [[::UbuntuWiki:VersionControlledEtc/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/fr | • {{#if: UbuntuWiki:VersionControlledEtc|français| [[::UbuntuWiki:VersionControlledEtc/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/gu | • {{#if: UbuntuWiki:VersionControlledEtc|ગુજરાતી| [[::UbuntuWiki:VersionControlledEtc/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/he | • {{#if: UbuntuWiki:VersionControlledEtc|עברית| [[::UbuntuWiki:VersionControlledEtc/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/hu | • {{#if: UbuntuWiki:VersionControlledEtc|magyar| [[::UbuntuWiki:VersionControlledEtc/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/id | • {{#if: UbuntuWiki:VersionControlledEtc|Bahasa Indonesia| [[::UbuntuWiki:VersionControlledEtc/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/it | • {{#if: UbuntuWiki:VersionControlledEtc|italiano| [[::UbuntuWiki:VersionControlledEtc/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/ja | • {{#if: UbuntuWiki:VersionControlledEtc|日本語| [[::UbuntuWiki:VersionControlledEtc/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/ko | • {{#if: UbuntuWiki:VersionControlledEtc|한국어| [[::UbuntuWiki:VersionControlledEtc/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/ksh | • {{#if: UbuntuWiki:VersionControlledEtc|Ripoarisch| [[::UbuntuWiki:VersionControlledEtc/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/mr | • {{#if: UbuntuWiki:VersionControlledEtc|मराठी| [[::UbuntuWiki:VersionControlledEtc/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/ms | • {{#if: UbuntuWiki:VersionControlledEtc|Bahasa Melayu| [[::UbuntuWiki:VersionControlledEtc/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/nl | • {{#if: UbuntuWiki:VersionControlledEtc|Nederlands| [[::UbuntuWiki:VersionControlledEtc/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/no | • {{#if: UbuntuWiki:VersionControlledEtc|norsk| [[::UbuntuWiki:VersionControlledEtc/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/oc | • {{#if: UbuntuWiki:VersionControlledEtc|occitan| [[::UbuntuWiki:VersionControlledEtc/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/pl | • {{#if: UbuntuWiki:VersionControlledEtc|polski| [[::UbuntuWiki:VersionControlledEtc/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/pt | • {{#if: UbuntuWiki:VersionControlledEtc|português| [[::UbuntuWiki:VersionControlledEtc/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/ro | • {{#if: UbuntuWiki:VersionControlledEtc|română| [[::UbuntuWiki:VersionControlledEtc/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/ru | • {{#if: UbuntuWiki:VersionControlledEtc|русский| [[::UbuntuWiki:VersionControlledEtc/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/si | • {{#if: UbuntuWiki:VersionControlledEtc|සිංහල| [[::UbuntuWiki:VersionControlledEtc/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/sq | • {{#if: UbuntuWiki:VersionControlledEtc|shqip| [[::UbuntuWiki:VersionControlledEtc/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/sr | • {{#if: UbuntuWiki:VersionControlledEtc|српски / srpski| [[::UbuntuWiki:VersionControlledEtc/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/sv | • {{#if: UbuntuWiki:VersionControlledEtc|svenska| [[::UbuntuWiki:VersionControlledEtc/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/th | • {{#if: UbuntuWiki:VersionControlledEtc|ไทย| [[::UbuntuWiki:VersionControlledEtc/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/tr | • {{#if: UbuntuWiki:VersionControlledEtc|Türkçe| [[::UbuntuWiki:VersionControlledEtc/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/vi | • {{#if: UbuntuWiki:VersionControlledEtc|Tiếng Việt| [[::UbuntuWiki:VersionControlledEtc/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/yue | • {{#if: UbuntuWiki:VersionControlledEtc|粵語| [[::UbuntuWiki:VersionControlledEtc/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/zh | • {{#if: UbuntuWiki:VersionControlledEtc|中文| [[::UbuntuWiki:VersionControlledEtc/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/zh-hans | • {{#if: UbuntuWiki:VersionControlledEtc|中文(简体)| [[::UbuntuWiki:VersionControlledEtc/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuWiki:VersionControlledEtc | UbuntuWiki:VersionControlledEtc | {{#if: | :}}UbuntuWiki:VersionControlledEtc}}/zh-hant | • {{#if: UbuntuWiki:VersionControlledEtc|中文(繁體)| [[::UbuntuWiki:VersionControlledEtc/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuWiki:VersionControlledEtc|:UbuntuWiki:VersionControlledEtc|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :UbuntuWiki:VersionControlledEtc/zh | | {{#ifexist: UbuntuWiki:VersionControlledEtc/zh | | {{#ifeq: {{#titleparts:UbuntuWiki:VersionControlledEtc|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:UbuntuWiki:VersionControlledEtc|1|-1|}} | zh | | }}
- Launchpad Entry: https://launchpad.net/distros/ubuntu/+spec/etc-in-svn
- Created: Date(2006-05-17T13:56:05Z) by AndrewBeresford
- Contributors: AndrewBeresford KarlGoetz
- Packages affected: dpkg
Summary
The specification describes an enhancement to keep automated versioned history of files under /etc
.
Rationale
Over time, configuration changes occur and it is easy to forget why changes were made, or what was in a config file prior to the change. It becomes even more difficult when there are multiple administrators working on a machine over a period of time.
Use cases
- Andrew is a systems administrator and his mail server has stopped working. Richard, another administrator, made some changes a week ago but has now gone on holiday to his residence in France. Andrew is unsure what changes Richard made to the mail configuration, but he can use the automated version history to look at the changes made before Richard went away.
- Karl has a box which was working and set up the way he likes. After a failed
dist-upgrade
his system is left in a half configured state. He would find it benefical to be able to roll back to just before the upgrade. - Igor has a few servers upon which he has made identical bespoke modifications to
/etc
. He would like to be able to store these modifications centrally and then distribute them to his servers when he changes them.
Scope
Design
Implementation
So far I have tried out the following;
in /etc/
;
bzr init bzr add * bzr commit -m "Initial Import"
then I added the following to roots crontab;
0 * * * * cd /etc; bzr commit -v -m "Automated update at `date`" >& /dev/null
Code
Some proof of concept code is avaialable via bzr from http://www.cs1ajb.staff.shef.ac.uk/bzr/auto-bzr/. You can download it using bzr using
bzr branch http://www.cs1ajb.staff.shef.ac.uk/bzr/auto-bzr/
Data preservation and migration
Outstanding issues
- Depending on implementation, files modified by a user could fail to be updated in VCS.
- Automating this process at the dpkg level would be highly intrusive.
- is bzr the right choice? I think it is, but what do I know?!
- Is it useful to get dpkg to update the bzr tree when it does things in /etc?
- Can we use DPkg::Pre-Invoke and DPkg::Post-Invoke in apt to integrate with package management better?
BoF agenda and discussion
- I'd say it's very useful to integrate this with dpkg, so that items changed due to package upgrades are shown as being done by a different user in the logs.
- It would be useful to make this tool as generic as possible - such that other directories can be configured to be tracked and even results of applications, such as dpkg
--get-selections
Comments
AchimBohnet:
- poluting /etc/ with version info files/dirs is a no-no IMHO. FWIW, I use svk because it does not add .<whatever> to every dir like svn (I have not tried bzr yet)
- Pkg tracking _including version_ is important. dpkg --get-selections does contain this info
- support for at least 1 commit per apt-get install/(dist-)upgrade is IMO very important (ala apt-listchanges), One commit for each installed or upgraded pkg level would be nice to have. At least one has to check that before pkg changes /etc is in a clean state so user and pkg changes don't mix.
- AndrewBeresford: a) I rewrote above item. Better? b) I even don't like one 模板:.bzr per managed tree. find and locate don't like the duplicates too (at least in the svn case ;) That's of course IMHO.
- Unfortunately there are still automaticly modified files /etc, e.g., /etc/adjtime and /etc/mtab. IMHO such files need to be ignored and not put under version control. So a mechanism for igore-files right from start is needed.
AndrewBeresford:
- AchimBohnet, I agree with your comment about polluting
/etc
.bzr
does place files in a.bzr
directory, but only in the top level of the repository. That seems a reasonable trade off to me. dpkg --get-selections
doesn't seem to contain any version numbers when I run it. I'm not sure that using version management to log the output ofdpkg --get-selections
is the based way to do things anyway. Would it not be better to getdpkg
to log its actions to a file (/var/log/dpkg.log?).- I'm not sure I'm clear on your idea about 1 commit per multiple installed/removed package. What I'd thought up was running the
bzr commit
at the very end of adpkg
action and logging with a commit message like "<name of package> <version> installed". You could also run thebzr commit
at the beginning ofdpkg
, but my concern would be the performance decrease. Doesdpkg
have a mechanism for running arbitrary commands at the beginning/end of a session? Something, like a global preinst/postinst script that gets run for every package installed/removed? Update: This can be done through apt hooks - not quite as good as going through dpkg, but much more straightforward/less invasive than modifying dpkg to do it.
PaulSchulz:
- GIT can also be used as the repository management tool. Using packages 'git-core', 'git-doc' and 'gitk'.
Eg. In /etc/
, using /var/git/etc.git
to hold the repository.
mkdir /var/git GIT_DIR=/var/git/etc.git git init-db GIT_DIR=/var/git/etc.git git add . GIT_DIR=/var/git/etc.git git commit -m "Initial Import"
- Other features:
- Only 'selected' files are tracked for changes.
gitk
can be used to quickly search for changes.- Commits and Tags can be signed.
- Entire directory state can be stored and restored (Igor), and branching also supported, eg. Igor has to support multiple machines which generally are the same but have a few minor differences.
- Could be used to test configurations in 'chroot' cages or virtual machines.
Huerlisi (Simon Huerlimann):
We're working on a set of scripts to do exactly this: managing the configuration files in /etc using a SCM. We settled on Git/Cogito to do the main work. The tool is called IsiSetup is just now getting a home: http://www.isisetup.ch/
[update] I've implemented the dpkg integration some of you mention. IsiSetup now creates a package branch using the package configuration when apt-get installing a package. This configuration is then fetched into /etc.
I'm blogging about some of the concepts and implementation of IsiSetup at http://huerlisi.wordpress.com. The website for IsiSetup currently gets some love, but is still incomplete and links are broken as we move documents from our internal wiki to this site. Please mail me at [email protected] if you'd like to know more or have some suggestions:-)
StefanMichalowski:
- could inotify be used to monitor changes on files in /etc for those cases where the user or some application modifies a file?
- could dbus be used to send a message when a file is modified in /etc, which could then be captured and used to create a commit?
- instead of using svn,cvs,bzr or any other version control system, would it be possible to mount /etc on a versioned-fs, such as one of the following fuse implementations:
- copyfs: http://n0x.org/copyfs/
- wayback: http://wayback.sourceforge.net/
Comments moved from ServerCandy specification
Merge updated package configuration
Does this advance also include other improvements over Debian's conffile handling? Right now, it only guarantees two versions (the old installed version and and the new package version) are available to examine, and leaves many openings for screw-ups in configuration. A better way would seem to be a three-way merge from the packaged version that the running version in /etc descended from. Basically, I see some nice ideas about keeping better track of /etc, that a lot of sysadmins do on their own, but nothing about integration with the package management system, which is where the real opportunity for advance lies.
Decision to choose bzr
What was the reason to choose bzr above other source control systems?
Was the main reason that bzr has the nice feature that there's only a single .bzr in the top level directory?
I suggest that the Svk project be considered, as it has the same feature. However, svk sits above Subversion, which has proved itself as a reliable source control system and many server admins are familair with it.
It seems a little odd to trust a relatively brand new source control system on an OS that's going to be supported for 5 years. I would rather see something that people are familiar with, even if it doesn't have all of bzr's sexy features.
bzr requirements
(We should probably create a separate spec for the bzr implications)
I'd like to clarify a bit more just what the use cases for this are. Is it just to keep a record of previous configurations and to allow admins to manually diff and roll back?
I think the bzr side of this is practical for dapper -- indeed I might start tracking my /etc in bzr just to see how it goes.
bzr 0.6.2 handles versioning of files, directories and symlinks. On my breezy machine there are no other file types in /etc; if we wanted to handle sockets or similar things in there that would need to be fixed. (But it is rather unclear to me how we could usefully version them; presumably the program that owns them would recreate them and anyhow they should probably be in /var or /dev.)
The main thing that would need to be fixed is to track permissions and ownership. This should not be too hard to do but will require some new code.
At the moment bzr assumes that working copy files are writable - if you try to update a file that's readonly you will get an error. This is probably a feature in typical use but one *might* want to overwrite it for versioning of /etc. This is probably OK if the admin is going to make any reversions manually.
Hardlinked working files would probably also cause confusion but I don't see any of them in /etc either.