ansible-playbook: how to dynamically, conditionally set a large deployment environment (variable space) in a playbook?
Yes, an input host file for ansible looks like https://pastebin.com/Vtfw5FtV
The upper part node stuff is generated using terraform, we can dynamically up/down scale the number of nodes with terraform and terraform outputs the yaml used for the hosts part of the file. The tenant-specifiek yml vars (about 150 additional lines of tenant specific config yml) are kept in a separate git location and a jenkins step/python concatenates them together and pushes them to the host directory location for each tenant and runs individual roles (hotfix) or all of 'em (full deploy) or perhaps just stop/start. The Jenkins job is pretty much a control screen with a lot of dropdowns, radio buttons and selectors. We can select how many nodes we want for a single service, which build to grab from nexus, do a full deploy, a single service hotfix or just a configuration hotfix. All this is selectable/executable per environment, per tenant and per individual module/service. The Jenkins screen is dynamically build from the host (targets) &amp; roles (actions) directory.
Again, we're most likely abusing Ansible &quot;best practices&quot; a fair bit but for us this approach has been working remarkably well for last &gt;3 years in terms of overall manageability and gives us maximum flexibility of the whole CI/CD pipeline.