Automating Linux container maintenance
I was a big fan of the LxdMosaic for several reasons. Mostly because of the graphical interface, but several other nice features was available to me. To list a few:
After canonicals decision to sorely abandon LXD completely and instead introduce incus as the abstraction layer over virtualization on the Ubuntu and Debian distros, the LxdMosaic is now none functional. The first and biggest pain point in this turn of event, is the ability to automate patching of all the instances. The solution was not that hard to make, so I shares my basic solution here. Bear in mind that this is crude and I strongly advises everyone to tailor this to their own specific needs...!
#!/bin/bash
declare -a myArr
myremotes=( $(sudo incus remote list -c n -f csv | grep -v "images") )
for a in "${myremotes[@]}"
do
if [ $a != '(current)' ]
then
myarray=( $(incus list $a: -c n -f csv) )
for i in "${myarray[@]}"
do
echo ""
echo "Updating: $i of $a"
echo "-----------------"
eval incus exec $a:$i -- /root/update.sh
echo "*****************"
done
fi
done
The above expects to find a local script - update.sh - on each instance. This provides a lot of flexibility as you can tailor update and upgrade procedures specifically for each individual instance if needs be.
To break it down:
Hope someone can make a litte bit use of this.