managing xml fragments a la lineinfile

Does anyone here a good tip for managing parts of xml files
(like lineinfile / blockinfile but xml-aware)?

I have several fairly complex apps to manage, each with their own role.
Ideally they'd each manage their own subset of the domain.xml,
which rules out a single domain.xml template.

ansible-xml looked perfect until I tried it and found it doesn't actually
work :frowning: [ https://github.com/cmprescott/ansible-xml/issues/55 ]

My Plan B (make that 'H' by now) would be to have a master template
that pulled in 'sub-templates' via lookup_template() , but that sounds like
it'll get messy fast and involve hardcoding roles together.

Does everyone just template their XML? Are you crazy kids all using
YAML and JSON nowadays?

If each subset can be divided in to files that then can be assembled into one big file you can check out the Assemble module.
https://docs.ansible.com/ansible/assemble_module.html

Dick - it is do-able. I have done this for the app servers in my current contract. I would have done it where you are now had there been sufficient interest, time or investment.

Firstly, start off with a set xml file for each type of application (messy but necessary)
Secondly, identify differences and use jinja2 to have blocks to manage those unique bits of the jb config so that you can eventually have 1 master xml file and then sub-xml (child) templates purely for the unique blocks.

However, you have to be very strict on future changes made to the domain.xml file via the cli or manual xml changes by admins. Your challenge will be to ensure all changes are pushed to you/other ansible-folk.

It works a treat, but considerable engineering/research/testing required.

DR.