

you could use shell scripts, but that might get very complex very quick, thats where ansible comes in. you make a playbook with the tasks to get a server from vanilla OS to how you want it.
tasks can do anything from install a package (with yum or apt or dnf) to uploading files and everything else you might need, the docs are quite good and have good examples.
As a user for about 9 years, both homelab and work. It can be overwhelming at first, but then you start to see why its used so much.
I run swarm in my homelab and have done for years, traefik runs on my manager and uses the docker swarm networks to get to services.
My traefik compose makes all the service networks, then each service compose has an external network that all the containers connect to.
This is my example config, this might help - https://github.com/mhzawadi/docker-stash/tree/master/swarm