There's a pretty neat Proxmox API library written in Go that can do this all for you: https://github.com/luthermonson/go-proxmox
There's a Terraform plugin planned, as well. Not sure what the status on it is, currently.
I also am slowly working on my own Proxmox CLI, consuming the go-proxmox library: https://github.com/perchnet/gomox
But unfortunately I don't have much software engineering experience, so it's a very slow process... :)
I try to do everything without Ansible: cloud-init is pretty powerful, too, but I am reaching the 64k limit, so sooner then later will go "back" to Ansible.
Have a look at this script for example https://github.com/francescor/swarm/blob/main/create_swarm_v... which is the "proxmox" side of cloud-init, that then load an ordinary cloud-init https://github.com/francescor/swarm/blob/main/cloud-init/clo...
...
# remove snapd trash
- snap remove lxd
- snap remove core20
- snap remove snapd
- systemctl stop snapd.service
- systemctl stop snapd.socket
- systemctl stop snapd.seeded.service
- systemctl disable snapd.service
- systemctl disable snapd.socket
- systemctl disable snapd.seeded.service
- systemctl stop snapd.service
- systemctl stop snapd.socket
- systemctl stop snapd.seeded.service
- rm -rf /var/cache/snapd/
- apt autoremove --purge snapd -y
- rm -rf /root/snap
# remove apport trash
...