Sorry for necro-bumping, I found this post very useful and just wanted to add my $0.02 mentioning a tool that makes INI file “very easy to manipulate via scripts”:

https://github.com/pixelb/crudini

I’ve been using it for several years now, it’s not perfect but has served me well for manipulating mysql, openstack and ceph configs to name a few.

Cheers!