From 07294722562dcd07dab69d69fbe2e9ba3b618de9 Mon Sep 17 00:00:00 2001 From: Benjamin Diaz Date: Mon, 27 Nov 2017 16:45:12 -0300 Subject: [PATCH] Make Rabbitmq config files overridable Rabbitmq config files can be overrided in node_custom_config directory. Change-Id: Id724b44a3edd951fa8b06c9f2c347e9ed8c5ffd9 Closes-Bug: #1674446 --- ansible/roles/rabbitmq/handlers/main.yml | 4 +- ansible/roles/rabbitmq/tasks/config.yml | 59 ++++++++++++++++++++---- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/ansible/roles/rabbitmq/handlers/main.yml b/ansible/roles/rabbitmq/handlers/main.yml index d25f4e2ef7..6e69358352 100644 --- a/ansible/roles/rabbitmq/handlers/main.yml +++ b/ansible/roles/rabbitmq/handlers/main.yml @@ -52,5 +52,7 @@ - inventory_hostname != groups[service.group]|first - service.enabled | bool - config_json.changed | bool - or rabbitmq_confs.changed | bool + or rabbitmq_env_conf.changed | bool + or rabbitmq_config.changed | bool + or rabbitmq_definitions.changed | bool or rabbitmq_container.changed | bool diff --git a/ansible/roles/rabbitmq/tasks/config.yml b/ansible/roles/rabbitmq/tasks/config.yml index df42bbe1b5..22334723b4 100644 --- a/ansible/roles/rabbitmq/tasks/config.yml +++ b/ansible/roles/rabbitmq/tasks/config.yml @@ -27,22 +27,63 @@ - Restart rabbitmq container (first node) - Restart rabbitmq container (rest of nodes) -- name: Copying over rabbitmq configs +- name: Copying over rabbitmq-env.conf + become: true vars: service: "{{ rabbitmq_services['rabbitmq'] }}" template: - src: "{{ item }}.j2" - dest: "{{ node_config_directory }}/{{ project_name }}/{{ item }}" + src: "{{ item }}" + dest: "{{ node_config_directory }}/{{ project_name }}/rabbitmq-env.conf" mode: "0770" - become: true - register: rabbitmq_confs + with_first_found: + - "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/rabbitmq-env.conf" + - "{{ node_custom_config }}/rabbitmq/rabbitmq-env.conf" + - "rabbitmq-env.conf.j2" + register: rabbitmq_env_conf + when: + - inventory_hostname in groups[service.group] + - service.enabled | bool + notify: + - Restart rabbitmq container (first node) + - Restart rabbitmq container (rest of nodes) + + +- name: Copying over rabbitmq.conf + become: true + vars: + service: "{{ rabbitmq_services['rabbitmq'] }}" + template: + src: "{{ item }}" + dest: "{{ node_config_directory }}/{{ project_name }}/rabbitmq.conf" + mode: "0770" + with_first_found: + - "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/rabbitmq.conf" + - "{{ node_custom_config }}/rabbitmq/rabbitmq.conf" + - "rabbitmq.conf.j2" + register: rabbitmq_config + when: + - inventory_hostname in groups[service.group] + - service.enabled | bool + notify: + - Restart rabbitmq container (first node) + - Restart rabbitmq container (rest of nodes) + +- name: Copying over definitions.json + become: true + vars: + service: "{{ rabbitmq_services['rabbitmq'] }}" + template: + src: "{{ item }}" + dest: "{{ node_config_directory }}/{{ project_name }}/definitions.json" + mode: "0770" + with_first_found: + - "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/definitions.json" + - "{{ node_custom_config }}/rabbitmq/definitions.json" + - "definitions.json.j2" + register: rabbitmq_definitions when: - inventory_hostname in groups[service.group] - service.enabled | bool - with_items: - - "rabbitmq-env.conf" - - "rabbitmq.conf" - - "definitions.json" notify: - Restart rabbitmq container (first node) - Restart rabbitmq container (rest of nodes)