I use ansible to generate yaml files which are then passed to other playbooks. I haven't found a need to dynamically generate an entire playbook since you can control behavior just by passing different variables to playbooks.
As well as getting to grips with roles, it would be well worth understanding what you can do with jinja2 templates, since the containers you mention all have lots of configuration in xml and properties files. Also, understand ansible's notion of inventory and groups. Once you have a handle on inventory groups you can start applying changes to logical sets of servers.
Selecting which server to apply a cert to based on its hostname should be fairly straightforward.
We are using smaller containers than you and ansible works well for deploying lots of different server types that we use, and applying rolling updates to our clusters.
Really its going to depend on what you are trying to do. If you can go into more detail about what your 'complex middleware use cases' are maybe others will have more specific relevant experience to share.
Jon