From 26485b8c7b650648e7f92733436d6699cbdd972a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Baufaker=20R=C3=AAgo?= Date: Mon, 9 Oct 2023 17:09:31 -0300 Subject: [PATCH] Add a custom broker.id based in a inventory file --- roles/amq_streams_broker/README.md | 1 + roles/amq_streams_broker/tasks/main.yml | 2 +- roles/amq_streams_broker/tasks/service.yml | 2 +- roles/amq_streams_broker/templates/server.properties.j2 | 3 ++- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/roles/amq_streams_broker/README.md b/roles/amq_streams_broker/README.md index c981078..e6d08d6 100644 --- a/roles/amq_streams_broker/README.md +++ b/roles/amq_streams_broker/README.md @@ -81,6 +81,7 @@ broker4 |`amq_streams_broker_auth_listeners` | Default list of authenticated listeners | `PLAINTEXT:PLAINTEXT` | |`amq_streams_broker_auth_sasl_mechanisms` | Default list of authenticated SASL mechanism | `PLAIN` | |`amq_streams_broker_inventory_group` | Identify the group of broker nodes | `groups['brokers']` | +|`amq_streams_broker_broker_id` | Identify the broker with specific id in the inventory |`amq_streams_broker_topics` | List of topics to create. Each topics requires the `name` property, and optionally the `partitions` and `replication_factor`. | | ## Role Variables diff --git a/roles/amq_streams_broker/tasks/main.yml b/roles/amq_streams_broker/tasks/main.yml index ba6cd68..1990df0 100644 --- a/roles/amq_streams_broker/tasks/main.yml +++ b/roles/amq_streams_broker/tasks/main.yml @@ -46,7 +46,7 @@ - name: "Set server_id for {{ amq_streams_broker.service_name }} service." ansible.builtin.set_fact: - server_id: "{{ broker_id | default('0') }}" + server_id: "{{ amq_streams_broker_broker_id | default('0') }}" when: - not server_id is defined diff --git a/roles/amq_streams_broker/tasks/service.yml b/roles/amq_streams_broker/tasks/service.yml index 3594d9a..49f9f49 100644 --- a/roles/amq_streams_broker/tasks/service.yml +++ b/roles/amq_streams_broker/tasks/service.yml @@ -29,7 +29,7 @@ server_start: "{{ amq_streams_broker.server_start }}" server_config: "{{ amq_streams_broker_config }}" server_config_template: "{{ amq_streams_broker.config.template }}" - server_id: "{{ broker_id | default('0') }}" + server_id: "{{ amq_streams_broker_broker_id | default('0') }}" server_user: "{{ amq_streams_broker_user | default(omit) }}" server_group: "{{ amq_streams_broker_group | default(omit) }}" server_log_dir: "{{ amq_streams_broker_logs_dir | default(omit) }}" diff --git a/roles/amq_streams_broker/templates/server.properties.j2 b/roles/amq_streams_broker/templates/server.properties.j2 index 0a6c759..7d81845 100644 --- a/roles/amq_streams_broker/templates/server.properties.j2 +++ b/roles/amq_streams_broker/templates/server.properties.j2 @@ -23,7 +23,8 @@ ############################# Server Basics ############################# # The id of the broker. This must be set to a unique integer for each broker. -broker.id={{ amq_streams_broker_inventory_group.index(inventory_hostname) }} +broker.id={{ amq_streams_broker_broker_id | default(amq_streams_broker_inventory_group.index(inventory_hostname)) }} + ############################# Socket Server Settings #############################