I would like to have one central git repository for all my servers' etckeeper .git repos. Here the suggestion was to use a file in /etc/etckeeper/commit.d, which basically looks like this, assuming that a git repo had been set up in somedir on somehost:
#!/bin/sh
cd /etc
git push faruser@farhost:somedir
The problem with this is, that it would be really nice to have all servers in the same repo on the central server. I tried
git push faruser@farhost:somedir/server1
but that failed.
As you can see, I've never worked with git before ... Any ideas on how this can be accomplished is greatly appreciated :)
Cheers,
Andreas
In addition to the good answer from pjz, here is how it could be done, step by step:
Create the file /etc/etckeeper/commit.d/60-push (dont forget to chmod+x it) on the clients.
central_server is defined in the ssh config, see below. /var/git/client_name.git is the directory on the central server, containing the git repo.
The ~/.ssh/config from root(!) should contain something like this:
Then you need to init the git repo on the central_server
Test it with a minor edit in /etc and then a etckeeper commit "test push'ing".
You have to set up the remote host is such an way, that the local user (i asume root, as you use etckeeper) is allowed to push to the remote repository. How to do this is depending on the way you want your git-repos on the remote-site to be published/available. For example when using git via ssh you would most likely setup an sshkey-pair without passphrase and therefor allow the the local root to login at the reomteside without (keyoard-,...) ineraction. And yes, when pushing to the remote site, the repository has to be existing, so at least an empty repo has to be present. So first tell us the exact situation you working with and the exact error your getting.
I can understand wanting a central place with all your config info, but you probably want them to still be their own separate repositories, just in a central location. To do so, lookup how to push to remote locations in git (using git push). Then you'll need to set up access to that location from all your servers, at which point you can push from all of them. At which point the suggestion you pointed to should work.
I think that the initial question is how to push to different branches in the same repo. One way to archive this is to use the syntax:
This will push the local 'master' branch to the remote 'server1' branch. You can have variation on this, such as:
Several remarks:
as all branch do not have a common ancestor, you will perhaps need a --force for the first commit
for the same reason, in the remote repo, you will see n linear independent history. In particular, you won't easily see the common part of your various branch. Idea for a project: take several git branch, create new ones to share common update and ensure that state in initial commits are also present in commits rewritten (i.e. rewrite the history by adding commit/merge/... but be sure to see the state of the initial commits)
At least on debian there is an option in etckeeper.conf.
After manually adding remote to git repos it should work out of the box