X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tasks%2Frabbitmq_ha_config.yml;h=322172d86ed97735ee3b0eb9883de8a3ae06bbb9;hb=fa6c482bae5ea36e52b575281feeab2649a8321f;hp=cea301ccfd431301870c98c8e8647784c865c177;hpb=d58696271f166b50faa2705fdda6337c1ffb493c;p=github%2Ffretlink%2Fansible-rabbitmq.git diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml index cea301c..322172d 100644 --- a/tasks/rabbitmq_ha_config.yml +++ b/tasks/rabbitmq_ha_config.yml @@ -13,9 +13,18 @@ notify: restart rabbitmq-server when: not rabbitmqadmin_check['stat']['exists'] +- name: rabbitmq_ha_config | creating exchange(s) + command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }} --vhost={{ item['vhost'] | default('/') }} + run_once: true + delegate_to: "{{ rabbitmq_master }}" + become: true + with_items: "{{ rabbitmq_config }}" + when: item['exchange_name'] is defined + - name: rabbitmq_ha_config | creating queue(s) command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }} --vhost={{ item['vhost'] | default('/') }} run_once: true + delegate_to: "{{ rabbitmq_master }}" become: true when: - item['queue_name'] is defined @@ -32,20 +41,15 @@ policy_vhost: "{{ item.vhost | default('/') }}" policy_name: "{{ item.policy_pattern is defined | ternary(policy_vhost + item.policy_pattern|default(''),item.queue_name|default('')) }}" run_once: true + delegate_to: "{{ rabbitmq_master }}" become: true when: item.queue_name is defined or item.policy_pattern is defined with_items: "{{ rabbitmq_config }}" -- name: rabbitmq_ha_config | creating exchange(s) - command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }} --vhost={{ item['vhost'] | default('/') }} - run_once: true - become: true - with_items: "{{ rabbitmq_config }}" - when: item['exchange_name'] is defined - - name: rabbitmq_ha_config | creating binding(s) command: rabbitmqadmin declare binding source={{ item['exchange_name'] }} destination_type="queue" destination={{ item['queue_name'] }} routing_key={{ item['routing_key'] }} --vhost={{ item['vhost'] | default('/') }} run_once: true + delegate_to: "{{ rabbitmq_master }}" become: true with_items: "{{ rabbitmq_config }}" when: item['exchange_name'] is defined