How to automate configuration

This is possible, my question would be why do you need this? Are you provisioning lots of sites?

A site backup and a copy of your app.yml is all that you need to recreate an identical site on another server.

On top of that, settings are persistent across rebuilds, so no need to worry about local upgrades on the same server.

If you need to create a site template, I believe you could achieve that with just a single backup and a template app.yml. You can modify site settings in app.yml if you choose to do so.