Skip to content

Version control of your configurations

vjrj edited this page Mar 6, 2020 · 6 revisions

Intro

Additionally to backup your servers, is important to keep track your changes in your:

  • your ansible inventories
  • and servers
    • /etc/
    • /data/*/config

Ansible inventories

Is quite important to keep track of your changes in your local inventories over the time so you can compare with upgrades, or rollback some change if something goes wrong.

You don't need to publish your git repositories in github a bare git repo in some of your servers can work so you and your team can access via them via ssh:

For instance in the tanbif-launcher server in Tanzania (a server we use to store our inventories but also to run ansible) we did like this:

mkdir ~/private-repos
cd ~/private-repos

# We create the empty repos
git init --bare tz-inventories.git
git init --bare tz-extra-inventories.git

cd ~/tanzania-inventories-2020/tz/

# We add the remote origin
git remote add origin ubuntu@tanbif-launcher:/home/ubuntu/private-repos/tz-inventories.git

# So we can commit our inventories there
git push --set-upstream origin master

So now you can have a copy of this inventories in your laptop a commit/push changes later with the rest of the team:

git clone  ubuntu@tanbif-launcher:/home/ubuntu/private-repos/tz-inventories.git
cd tz-inventories

Keeping track of changes in /etc directory

You can use some tool like etckeeper to track your changes in your /etc folders. See this for more instructions.

Keep track of the changes in your /data/*/config directories

We can do a similar thing with the configuration of each LA module so after running ansible we can see the changes, the new variables, etc, keep version of the configurations and rollback if something were wrong.

cd /data/spatial-hub/config
git init .
git add --all
git commit -a -m "First init"

You can also add a remote private repo and to have all your config in a central server, so after installing a new, let say, spatial-hub you can restore easy the configs of a other spatial-hub instance.

So from time to time, you can verify your changes in the configuration:

root@gbif-spatial:/data/spatial-hub/config# git log
commit 9fd4db1375f97408b95b5cc895eaaaae271d41f8
Author: Your Name <you@example.com>
Date:   Thu Aug 1 10:56:52 2019 +0200

    Make head title work

commit 2e85763ceaa8fc92ba50353c7950abb107bc4c3f
Author: Your Name <you@example.com>
Date:   Fri Jul 26 19:06:27 2019 +0200

    Working with builded war

About maintaining /data/*/config/

About modifications in config, if you find a variable whatever_var no well configured, you can search it in ala-install with

grep -ri whatever_var ala-install/ansible

to know the ansible var name, so you can add to your inventories with the correct values, and rerun ansible-playbook with -tags properties or if you a using ansiblew with -p to upate only the config properties in your servers.

We don't recommend to do local changes in /data/*/config directly, only exceptionally when you want to test something fast, but try to do all your changes in my local inventories so a ansible rerun in the future (for instance in a LA update) doesn't break things

Clone this wiki locally