{"thread":{"id":"58612","subject":"How to best maintain directories like /etc/sysstat in GIT?","startedAt":"2022-10-12T16:42:59Z","lastAt":"2022-10-13T00:07:18Z","messageCount":2,"participants":["Thorsten Schöning","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"464729","messageId":"1681596318.20221012183551@am-soft.de","threadId":"58612","inReplyTo":null,"subject":"How to best maintain directories like /etc/sysstat in GIT?","fromName":"Thorsten Schöning","fromEmail":"tschoening@am-soft.de","sentAt":"2022-10-12T16:35:51Z","receivedAt":"2022-10-12T16:42:59Z","isPatch":false,"sender":{"key":"tschoening@am-soft.de","avatar":null},"body":"Hi everyone,\n\nI'm using SVN to maintain lots of different host specific configs like\ncrontab files, web server configs and the directory /etc/sysstat. The\ncurrent approach is to simply have some directory structure in trunk\nnamed by topics like /trunk/Mail/Postfix for some reference host, if\nany makes sense at all. That config is then copied to e.g.\n/tags/Mail/Postfix/some.other.host and Postfix for that host\nmaintained in that writable tag.\n\nGIT doesn't have writable tags, which might be worked around using\nbranches or one repo per host or stuff. The more important difference\nis that SVN can have a working copy for each and every maintained\ndirectory. So one can really make /etc/postfix or /etc/sysstat a\nwroking copy and maintained that only, without additionally necessary\nsubdirs and without having .svn in /etc or alike. AFAIK that is not\npossible in GIT, even with sparse checkouts one needs a subdir of\nsome kind, which is pretty incomplatible with many system wide\nconfigs. Unless one wants to put .git into / or /etc or alike, which\nis what I would loike to avoid.\n\nAny useful suggestions for workarounds?\n\nI can only think of two things: Putting the GIT clone somewhere and\nlink directories into that. Which won't work very well for directories\nfor which I only want to maintain some and not all files and seems\nlike a lot of work, might break package management etc.\n\nThe other thing I have in mind is using branches and their implicit\navailable ROOT. So I would create /etc/sysstat as branch name, clone\nsome repo into /etc/sysstat and checkout the corresponding branch\nname. That branch would only contain the files for that directory. For\nother directories other branch names would need to be created. The\nproblems I see are with introducing host names, branch name lengths\nand stuff.\n\nAny further ideas? Thanks!\n\nMit freundlichen Grüßen\n\nThorsten Schöning\n\n-- \nAM-SoFT IT-Service - Bitstore Hameln GmbH\nMitglied der Bitstore Gruppe - Ihr Full-Service-Dienstleister für IT und TK\n\nE-Mail: Thorsten.Schoening@AM-SoFT.de\nWeb:    http://www.AM-SoFT.de/\n\nTel:   +49 5151-  9468- 0\nTel:   +49 5151-  9468-55\nMobil: +49  178-8 9468-04\n\nAM-SoFT IT-Service - Bitstore Hameln GmbH, Brandenburger Str. 7c, 31789 Hameln\nAG Hannover HRB 221853 - Geschäftsführer: Janine Galonska\n\n\nFür Rückfragen stehe ich Ihnen jederzeit zur Verfügung. \n\nMit freundlichen Grüßen, \n\nThorsten Schöning\n\n\nTelefon: +49 5151 9468-55\nFax: \nE-Mail: TSchoening@am-soft.de\n\nAM-Soft IT-Service - Bitstore Hameln GmbH\nBrandenburger Straße 7c\n31789 Hameln\n\nDiese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen und ist ausschliesslich für den Adressaten bestimmt. Jeglicher Zugriff auf diese E-Mail durch andere Personen als den Adressaten ist untersagt. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Sollten Sie nicht der für diese E-Mail bestimmte Adressat sein, ist Ihnen jede Veröffentlichung, Vervielfältigung oder Weitergabe wie auch das Ergreifen oder Unterlassen von Massnahmen im Vertrauen auf erlangte Information untersagt. \n\nThis e-mail may contain confidential and/or privileged information and is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. \n\nHinweise zum Datenschutz: bitstore.group/datenschutz\n\n\n\n"},{"id":"464790","messageId":"Y0dWrAba6U+j0tT9@tapette.crustytoothpaste.net","threadId":"58612","inReplyTo":"1681596318.20221012183551@am-soft.de","subject":"Re: How to best maintain directories like /etc/sysstat in GIT?","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2022-10-13T00:07:08Z","receivedAt":"2022-10-13T00:07:18Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2022-10-12 at 16:35:51, Thorsten Schöning wrote:\n> Hi everyone,\n> \n> I'm using SVN to maintain lots of different host specific configs like\n> crontab files, web server configs and the directory /etc/sysstat. The\n> current approach is to simply have some directory structure in trunk\n> named by topics like /trunk/Mail/Postfix for some reference host, if\n> any makes sense at all. That config is then copied to e.g.\n> /tags/Mail/Postfix/some.other.host and Postfix for that host\n> maintained in that writable tag.\n> \n> GIT doesn't have writable tags, which might be worked around using\n> branches or one repo per host or stuff. The more important difference\n> is that SVN can have a working copy for each and every maintained\n> directory. So one can really make /etc/postfix or /etc/sysstat a\n> wroking copy and maintained that only, without additionally necessary\n> subdirs and without having .svn in /etc or alike. AFAIK that is not\n> possible in GIT, even with sparse checkouts one needs a subdir of\n> some kind, which is pretty incomplatible with many system wide\n> configs. Unless one wants to put .git into / or /etc or alike, which\n> is what I would loike to avoid.\n> \n> Any useful suggestions for workarounds?\n\nThere are a couple approaches you can take.  One is to keep the\nrepository elsewhere and simply copy files into place.  This is how I\nand many people manage our respective dotfiles with Git.\n\nAnother option is to use some sort of automatic system for managing\nthose config files, such as Puppet, Chef, or Ansible, and keep those\nfiles in a repository suitable for that system.  This is how I manage\nconfiguration for my servers and how we do it at work.\n\nFinally, you can also keep the Git directory separate from the working\ntree.  For example, if you're in /etc and your repository directory is\n/srv/checkouts/etc-git, you can run one of the following:\n\n$ GIT_WORK_TREE=/etc GIT_DIR=/srv/checkouts/etc-git git status\n$ git --work-tree=/etc --git-dir=/srv/checkouts/etc-git status\n\n(Note that you must set both environment variables or both options, not\njust one.)  Of course, this is a little unwieldy, so a shell script may\nbe helpful.  You'll also want an appropriate .gitignore file.\n\n> I can only think of two things: Putting the GIT clone somewhere and\n> link directories into that. Which won't work very well for directories\n> for which I only want to maintain some and not all files and seems\n> like a lot of work, might break package management etc.\n\nGit does not preserve hard links and this won't work in general.  Since\nGit also does not preserve permissions other than the executable bit, so\nyou almost certainly will not want to use symlinks, either, since that\nmeans the destination directories may change ownership and permissions\nwhen you run git checkout.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"}]}