Last Updated: February 25, 2016
·
12.26K
· fluxsauce

Installing etckeeper to store config with autopush to git in Ubuntu 14.04 LTS

etckeeper - https://github.com/joeyh/etckeeper - is a great utility for automatically storing your server configuration in git, because configuration should be tracked like any other program. Ubuntu includes a package for it, but by default it uses Bazzar (Canonical's versioning system) instead of git as the author intended. To quote the README:

It's possible that your distribution has chosen to modify etckeeper so its default VCS is not git -- if they have please complain to them, as they're making things unnecessarily difficult for you, and causing unnecessary divergence of etckeeper installations.

Yup.

Takes a bit of tweaking out-of-the-box. Let me save you some time.

# Login as root.
sudo su
# Install etckeeper.
apt-get -y install etckeeper
# Edit the etckeeper configuration.
nano /etc/etckeeper/etckeeper.conf

Uncomment the GIT line and comment out bzr.

VCS="git"
#VCS="bzr"

Modify PUSH_REMOTE:

PUSH_REMOTE="origin"

Exit & save.

# Go to the configuration directory.
cd /etc
# Initialize etckeeper.
etckeeper init
# Add the remote repository.
git remote add origin git@HOSTNAME:REPONAME
# First commit.
etckeeper commit "Initial commit."
# Set the upstream and push.
git push -u origin master
# We're done here.
exit

Etckeeper will now automatically push commits to your git repository.

1 Response
Add your response

Browsing about this topic I found that if you have an application at the top of your stack with a configuration outside of /etc you can also store it's configuration in the etckeeper repository, to make commits to both application, stack and system configuration in the same changesets in the same repo:

https://www.turnkeylinux.org/forum/support/20151207/using-git-store-server-configuration

However, I still have some questions on this if you know anything about them:

http://unix.stackexchange.com/questions/249785/how-do-i-know-when-what-i-should-store-in-my-external-to-etc-configuraitons-in

http://unix.stackexchange.com/questions/250216/what-directory-does-etckeeper-store-its-permissions-meta-data-in

I understand however that if your repo gets to be too big, you can run etckeeper vcs gc if you're using git, and if it gets way too big you can get rid of the changes using etckeeper uninit.

Also I believe that it's also possible to use something like sshfs to mount a share on another machine if you wish to keep the etckeeper repo somewhere else where it won't take up so much space on the production server.

This is a pretty good post too: http://rsabalburo.blogspot.com/2011/09/sysadmin-guide-to-using-git-and.html

over 1 year ago ·