I decided to cut my code down to the bits that are relevant to postgres for what I'll show you. A handful of caveats:
* This is very WIP, along with some TODOs and other notes to self that you may want to consider as well (I'm happy to get critiques from you and others as well here; I was gonna solicit opinions on this eventually anyway)
* This may or may not be optimized for running multiple times; some parts may want to be split out for initialization
* This was written for spk, not vagrant-spk. Based on Debian Buster.
* It may not work out of the box. Again I ripped out everything unrelated.
* postrges.conf is a modified version of the default. I don't remember if I took notes on what I changed and why, but I should do so before releasing. Look for the "TODO"s there for at least a couple of them. And/or you could diff with the one in /etc/, or the one that gets generated in /var/ under normal circumstances when running postgres.
* The "/var/pgtest/x/" path stuff you see was probably just related to the tests I was doing, or maybe it was to avoid conflict with the existing installation of postgres. At any rate, I think nothing's particularly special about the path other than that it's under /var/
* There's probably extra noise in the "create superusers, create tables" part of it. It was the result of experimentation and I should cut it down to all I really need there. Also what I do there is related to the specific application I'm working on, but you should ideally be able to do any sort of table creations and queries at that point in the script.
Gonna try Gogs on for size for sharing this. If you visit this and click "Explore" you should see the repo with list of files:
Let me know if you have problems, I may have seen the same ones recently.
-Dan