add rabbitmq topics

This commit is contained in:
Louis Abel 2023-07-22 21:25:14 -07:00
parent 8d458ed5bb
commit ff5cb35875
Signed by: label
GPG Key ID: 3331F061D1D9990E
4 changed files with 44 additions and 1 deletions

32
tasks/rabbitmq/topics.yml Normal file
View File

@ -0,0 +1,32 @@
---
- name: Add topic exchanges
run_once: true
delegate_to: "{{ rabbitmq_cluster_list[0] }}"
community.rabbitmq.rabbitmq_exchange:
name: "{{ item.0.name }}"
exchange_type: "{{ item.0.exchange_type }}"
vhost: "{{ item.1.vhost }}"
login_user: "{{ rabbitmq_admin }}"
login_password: "{{ rabbitmq_admin_password }}"
loop: "{{ rabbitmq_topics | subelements('vhosts', 'skip_missing=True') }}"
when: rabbitmq_admin_password is defined
tags:
- rabbitmq_cluster
- name: Forward topics if configured
run_once: true
delegate_to: "{{ rabbitmq_cluster_list[0] }}"
community.rabbitmq.rabbitmq_binding:
destination_type: "{{ item.1.destination_type }}"
name: "{{ item.0.name }}"
dest: "{{ item.1.destination}}"
routing_key: "{{ item.1.routing_key }}"
vhost: "{{ item.1.vhost }}"
login_user: "{{ rabbitmq_admin }}"
login_password: "{{ rabbitmq_admin_password }}"
when:
- rabbitmq_admin_password is defined
- item.1.binding|bool
tags:
- rabbitmq_cluster
...

View File

@ -3,6 +3,7 @@
community.rabbitmq.rabbitmq_user: community.rabbitmq.rabbitmq_user:
user: "{{ item.user }}" user: "{{ item.user }}"
state: absent state: absent
loop: "{{ rabbitmq_users }}"
when: item.state == 'absent' when: item.state == 'absent'
- name: Add and configure single vhost users - name: Add and configure single vhost users

View File

@ -9,6 +9,7 @@ rabbitmq_tls_key: "/etc/pki/tls/private/{{ ansible_fqdn }}.key"
# rabbitmq_cookie: ... # rabbitmq_cookie: ...
# Admin passwords - these should be in a vault # Admin passwords - these should be in a vault
rabbitmq_admin: "rockyadmin"
# rabbitmq_admin_password: ... # rabbitmq_admin_password: ...
# rabbitmq cluster list and information should be defined in hostvars to ensure # rabbitmq cluster list and information should be defined in hostvars to ensure

View File

@ -1,4 +1,13 @@
--- ---
rabbitmq_topics: rabbitmq_topics:
- - name: "zmq.topic"
exchange_type: "topic"
vhosts:
- vhost: "public_pubsub"
destination: "amq.topic"
destination_type: "exchange"
routing_key: "#"
binding: true
- vhost: "pubsub"
binding: false
... ...