Open guidograzioli opened 1 month ago
One way we did this is to have a boolean variable to toggle modularization, and put the current behavior in a block for when it's false, and in a block for when it's true:
- name: Create address-settings file
ansible.builtin.template:
src: address_settings.modular.xml.j2
dest: "{{ amq_broker_dest + '/' + amq_broker_instance_name }}/etc/address-settings.xml"
- name: Remove address-settings element from broker.xml
redhat.runtimes_common.xml:
path: "{{ amq_broker_dest + '/' + amq_broker_instance_name }}/etc/broker.xml"
xpath: /conf:configuration/core:core/core:address-settings
state: absent
namespaces:
conf: urn:activemq
core: urn:activemq:core
- name: Import address-settings file
redhat.runtimes_common.xml:
path: "{{ amq_broker_dest + '/' + amq_broker_instance_name }}/etc/broker.xml"
xpath: /conf:configuration/core:core/xi:include[@href='{{ amq_broker_dest + '/' + amq_broker_instance_name }}/etc/address-settings.xml']
namespaces:
xi: http://www.w3.org/2001/XInclude
conf: urn:activemq
core: urn:activemq:core
pretty_print: true
Where the address_settings.modular.xml.j2
is
<?xml version="1.0" encoding="utf-8"?>
<address-settings xmlns="urn:activemq:core">
{% for address_setting in addressSettings %}
<address-setting match="{{ address_setting.match }}">
{% for param in lookup('ansible.builtin.dict', address_setting.parameters, wantlist=True) %}
<{{ param.key | replace('_','-') }}>{% if param.value is number %}{{ param.value | string | lower }}{% else %}{{ param.value }}{% endif %}</{{ param.key | replace('_','-') }}>
{% endfor %}
</address-setting>
{% endfor %}
</address-settings>
Creating the file this way without a looping task was a huge performance improvement for large lists.
edit: changed example to our address-settings because we did something else to our security-settings to fit the format of how we were importing them.
SUMMARY
Allow certain configurations to be kept in a (or 1+ modularized) separate file(s), imported via XInclude [1]
[1] https://activemq.apache.org/components/artemis/documentation/latest/configuration-index.html#modularising-broker-xml
ISSUE TYPE