Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

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.

share|improve this answer
1  
I've been looking at having a template config in the master and then creating a branch for each server so I can do server-specific stuff like networking-scripts etc. Does this approach make sense? –  Nicholas Tolley Cottrell Sep 26 '13 at 13:08
add comment

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.

share|improve this answer
add comment

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.

    #!/bin/sh
    git push central_server:/var/git/client_name.git master

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:

    host central_server
    Hostname 192.168.0.1
    User etckeeper #a user on the central server 
    IdentityFile ~/.ssh/custom_key # key is in authorized_keys in
                 #etcpeeper@central_server:~/.ssh/authorized_keys

Then you need to init the git repo on the central_server

    mkdir /var/git/client_name.git
    su etckeeper
    cd /var/git/client_name.git
    git --bare init

Test it with a minor edit in /etc and then a etckeeper commit "test push'ing".

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.