I am preparing some Ansible scripts for a service that works in a master/slave setup. There is a single docker image for both but the master/slave behavior will be acquired after configuring some environment variables.
When i explicitly setup each container, this is roughly how my playbook would look:
I've dealt with this in 2 different ways in the past depending on scale.
In both cases I have a single group (call it lb for loadbalancer) with
the nodes in it, but use dynamic lookups for the latter more complex
scenario.
In one case, I used per-host variables - effectively a manual
declaration: