diff --git a/ansible/roles/rabbitmq/defaults/main.yml b/ansible/roles/rabbitmq/defaults/main.yml index 4c059eadb00a80fc498c044f7a2b153f5600c7a5..46d907bf54bada9b5068ce91f687e6ca2ab90fbc 100644 --- a/ansible/roles/rabbitmq/defaults/main.yml +++ b/ansible/roles/rabbitmq/defaults/main.yml @@ -99,6 +99,10 @@ rabbitmq_ha_promote_on_shutdown: # "ha-mode":"exactly","ha-params":{{ rabbitmq_ha_replica_count | int }} rabbitmq_server_count: "{{ groups[role_rabbitmq_groups] | length }}" rabbitmq_ha_replica_count: "{{ (rabbitmq_server_count | int // 2 + 1) }}" +# If no TTL is specified, messages will not expire +rabbitmq_message_ttl_ms: +# If no queue expiry is specified, queues will not expire +rabbitmq_queue_expiry_ms: rabbitmq_extra_config: {} #################### diff --git a/ansible/roles/rabbitmq/templates/definitions.json.j2 b/ansible/roles/rabbitmq/templates/definitions.json.j2 index 4bf42d94810355df81a1e15df53ac54f51334f9f..1a7205de7d6d310f8d8ad34e18afc3944bfa779d 100644 --- a/ansible/roles/rabbitmq/templates/definitions.json.j2 +++ b/ansible/roles/rabbitmq/templates/definitions.json.j2 @@ -18,8 +18,8 @@ ], {% if om_enable_rabbitmq_high_availability | bool %} "policies":[ - {"vhost": "/", "name": "ha-all", "pattern": "^(?!(amq\\.)|(.*_fanout_)|(reply_)).*", "apply-to": "all", "definition": {"ha-mode":{% if rabbitmq_ha_replica_count is not none %}"exactly","ha-params":{{ rabbitmq_ha_replica_count | int }}{% else %}"all"{% endif %}{% if rabbitmq_ha_promote_on_shutdown is not none %},"ha-promote-on-shutdown":"{{ rabbitmq_ha_promote_on_shutdown }}"{% endif %}}, "priority":0}{% if project_name == 'outward_rabbitmq' %}, - {"vhost": "{{ murano_agent_rabbitmq_vhost }}", "name": "ha-all", "pattern": "^(?!(amq\\.)|(.*_fanout_)|(reply_)).*", "apply-to": "all", "definition": {"ha-mode":{% if rabbitmq_ha_replica_count is not none %}"exactly","ha-params":{{ rabbitmq_ha_replica_count | int }}{% else %}"all"{% endif %}{% if rabbitmq_ha_promote_on_shutdown is not none %},"ha-promote-on-shutdown":"{{ rabbitmq_ha_promote_on_shutdown }}"{% endif %}}, "priority":0} + {"vhost": "/", "name": "ha-all", "pattern": "^(?!(amq\\.)|(.*_fanout_)|(reply_)).*", "apply-to": "all", "definition": {"ha-mode":{% if rabbitmq_ha_replica_count is not none %}"exactly","ha-params":{{ rabbitmq_ha_replica_count | int }}{% else %}"all"{% endif %}{% if rabbitmq_ha_promote_on_shutdown is not none %},"ha-promote-on-shutdown":"{{ rabbitmq_ha_promote_on_shutdown }}"{% endif %}{% if rabbitmq_message_ttl_ms is not none %},"message-ttl":{{ rabbitmq_message_ttl_ms | int }}{% endif %}{% if rabbitmq_queue_expiry_ms is not none %},"expires":{{ rabbitmq_queue_expiry_ms }}{% endif %}}, "priority":0}{% if project_name == 'outward_rabbitmq' %}, + {"vhost": "{{ murano_agent_rabbitmq_vhost }}", "name": "ha-all", "pattern": "^(?!(amq\\.)|(.*_fanout_)|(reply_)).*", "apply-to": "all", "definition": {"ha-mode":{% if rabbitmq_ha_replica_count is not none %}"exactly","ha-params":{{ rabbitmq_ha_replica_count | int }}{% else %}"all"{% endif %}{% if rabbitmq_ha_promote_on_shutdown is not none %},"ha-promote-on-shutdown":"{{ rabbitmq_ha_promote_on_shutdown }}"{% endif %}{% if rabbitmq_message_ttl_ms is not none %},"message-ttl":{{ rabbitmq_message_ttl_ms | int }}{% endif %}{% if rabbitmq_queue_expiry_ms is not none %},"expires":{{ rabbitmq_queue_expiry_ms }}{% endif %}}, "priority":0} {% endif %} ] {% else %} diff --git a/releasenotes/notes/rabbitmq-add-flags-for-message-ttl-and-queue-expiry-c163a370708f5b20.yaml b/releasenotes/notes/rabbitmq-add-flags-for-message-ttl-and-queue-expiry-c163a370708f5b20.yaml new file mode 100644 index 0000000000000000000000000000000000000000..81947616bdb5bbd5a79b13d3611bbee314140a59 --- /dev/null +++ b/releasenotes/notes/rabbitmq-add-flags-for-message-ttl-and-queue-expiry-c163a370708f5b20.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Added two new flags to alter behaviour in RabbitMQ: + * `rabbitmq_message_ttl_ms`, which lets you set a TTL on messages. + * `rabbitmq_queue_expiry_ms`, which lets you set an expiry time on queues. + See https://www.rabbitmq.com/ttl.html for more information on both. diff --git a/tools/validate-all-file.py b/tools/validate-all-file.py index 763020e52b7961512c09a6b60bc203e02d677bd5..777c47b099f528c4f40329a0f4efa31e95de1111 100755 --- a/tools/validate-all-file.py +++ b/tools/validate-all-file.py @@ -128,6 +128,9 @@ def check_json_j2(): 'kolla_internal_fqdn': '', 'octavia_provider_drivers': '', 'rabbitmq_ha_replica_count': 2, + 'rabbitmq_message_ttl_ms': 600000, + 'rabbitmq_queue_expiry_ms': 3600000, + } data = template.render(**context) json.loads(data)