Version control of your configurations - AtlasOfLivingAustralia/documentation Wiki
- Ansible inventories
- Keeping track of changes in /etc directory
- Keep track of the changes in your /data/*/config directories
- About maintaining /data/*/config/
In addition to backing-up your servers, it is very important to keep track of changes in your:
- Ansible Inventories
- Ansible-configured (and manually-edited) server directories
It is quite important to keep track of changes in your local inventories over time so you can compare with upgrades, or rollback changes if something goes wrong.
You don't need to publish your Ansible Inventory git repositories to github. A bare git repo on 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 they use to store their inventories but also to run ansible) they did 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 [email protected]:/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 [email protected]:/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"
In one line you can do it for all services, for instance:
git config --global user.email "[email protected]" ; git config --global user.name "Support tanbif"; for i in `ls -d /data/*/config/` ; do (cd $i; git init . && git add --all && git commit -m "First init" && git status); done
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
So from time to time, you can verify your changes in the configuration:
[email protected]:/data/spatial-hub/config# git log commit 9fd4db1375f97408b95b5cc895eaaaae271d41f8 Author: Your Name <[email protected]> Date: Thu Aug 1 10:56:52 2019 +0200 Make head title work commit 2e85763ceaa8fc92ba50353c7950abb107bc4c3f Author: Your Name <[email protected]> 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 not well configured, you can search for it in
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
-tags properties or if you a using
-p to update only the config properties in your servers.
We don't recommend that you make local changes in
/data/*/config directly, except when you want to test something quickly, or to have changes take an immediate effect. You should make all configuration changes in local inventory files so that, when ansible is re-run in the future (for instance on performing an LA update), it doesn't undo the temporary changes made to configuration files in /data/*/config.