I'm wondering what is the best practice when deploying with Ansible this kind of situation (which is quite common):
- my.domain.com DNS rule must resolve to my proxy server
- the proxy server (nginx or whatever) serves content from my backend server
How to dispatch configuration to each server?
What I've done so far:
- host_var/my.domain.com -> nginx vhost configuration
- host_var/my.backend.com -> backend configuration
This choice is quite annoying, because it makes me create 2 subdomains each time:
- my.domain.com to resolve and store proxy configuration
- my.backend.com to resolve and store backend configuration
It seems OK for 1 single example, but when dealing with lots of services (think microservices) it seems to me it could be improved.
Do you think about another possible implementation?
If you want to group redundant configuration you have to put your servers in a group in your inventory file.
And then you create two files
group_vars/frontend.yml
group_vars/backend.yml
in which you put the configuration for the frontend and backend servers.
Ansible does not require, that you use any domain at all.