diff --git a/defaults/main.yml b/defaults/main.yml index f6705ec..8fdcaed 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -190,7 +190,13 @@ masakari_oslomsg_rpc_servers: "{{ oslomsg_rpc_servers | default('127.0.0.1') }}" masakari_oslomsg_rpc_port: "{{ oslomsg_rpc_port | default('5672') }}" masakari_oslomsg_rpc_use_ssl: "{{ oslomsg_rpc_use_ssl | default(False) }}" masakari_oslomsg_rpc_userid: masakari -masakari_oslomsg_rpc_vhost: /masakari +# vhost name depends on value of oslomsg_rabbit_quorum_queues. In case quorum queues +# are not used - vhost name will be prefixed with leading `/`. +masakari_oslomsg_rpc_vhost: + - name: /masakari + state: "{{ masakari_oslomsg_rabbit_quorum_queues | ternary('absent', 'present') }}" + - name: masakari + state: "{{ masakari_oslomsg_rabbit_quorum_queues | ternary('present', 'absent') }}" masakari_oslomsg_rpc_ssl_version: "{{ oslomsg_rpc_ssl_version | default('TLSv1_2') }}" masakari_oslomsg_rpc_ssl_ca_file: "{{ oslomsg_rpc_ssl_ca_file | default('') }}" @@ -208,6 +214,11 @@ masakari_oslomsg_notify_vhost: "{{ masakari_oslomsg_rpc_vhost }}" masakari_oslomsg_notify_ssl_version: "{{ oslomsg_notify_ssl_version | default('TLSv1_2') }}" masakari_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }}" +## RabbitMQ integration +masakari_oslomsg_rabbit_quorum_queues: "{{ oslomsg_rabbit_quorum_queues | default(True) }}" +masakari_oslomsg_rabbit_quorum_delivery_limit: "{{ oslomsg_rabbit_quorum_delivery_limit | default(0) }}" +masakari_oslomsg_rabbit_quorum_max_memory_bytes: "{{ oslomsg_rabbit_quorum_max_memory_bytes | default(0) }}" + ## (Qdrouterd) integration # TODO(ansmith): Change structure when more backends will be supported masakari_oslomsg_amqp1_enabled: "{{ masakari_oslomsg_rpc_transport == 'amqp' }}" diff --git a/templates/masakari.conf.j2 b/templates/masakari.conf.j2 index 541c115..0b0f862 100644 --- a/templates/masakari.conf.j2 +++ b/templates/masakari.conf.j2 @@ -1,6 +1,6 @@ [DEFAULT] enabled_apis = masakari_api -transport_url = {{ masakari_oslomsg_rpc_transport }}://{% for host in masakari_oslomsg_rpc_servers.split(',') %}{{ masakari_oslomsg_rpc_userid }}:{{ masakari_oslomsg_rpc_password }}@{{ host }}:{{ masakari_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ masakari_oslomsg_rpc_vhost }}{% if masakari_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ masakari_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ masakari_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ masakari_oslomsg_rpc_transport }}://{% for host in masakari_oslomsg_rpc_servers.split(',') %}{{ masakari_oslomsg_rpc_userid }}:{{ masakari_oslomsg_rpc_password }}@{{ host }}:{{ masakari_oslomsg_rpc_port }}{% if not loop.last %},{% else %}/{{ _masakari_oslomsg_rpc_vhost_conf }}{% if masakari_oslomsg_rpc_use_ssl | bool %}?ssl=1&ssl_version={{ masakari_oslomsg_rpc_ssl_version }}&ssl_ca_file={{ masakari_oslomsg_rpc_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} # Enable to specify listening IP other than default masakari_api_listen = {{ masakari_api_bind_address }} # Enable to specify port other than default @@ -67,6 +67,9 @@ process_all_instances = false [oslo_messaging_rabbit] ssl = {{ masakari_oslomsg_notify_use_ssl | bool }} +rabbit_quorum_queue = {{ masakari_oslomsg_rabbit_quorum_queues }} +rabbit_quorum_delivery_limit = {{ masakari_oslomsg_rabbit_quorum_delivery_limit }} +rabbit_quorum_max_memory_bytes = {{ masakari_oslomsg_rabbit_quorum_max_memory_bytes }} [oslo_messaging_notifications] -transport_url = {{ masakari_oslomsg_notify_transport }}://{% for host in masakari_oslomsg_notify_servers.split(',') %}{{ masakari_oslomsg_notify_userid }}:{{ masakari_oslomsg_notify_password }}@{{ host }}:{{ masakari_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ masakari_oslomsg_notify_vhost }}{% if masakari_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ masakari_oslomsg_notify_ssl_version }}&ssl_ca_file={{ masakari_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} +transport_url = {{ masakari_oslomsg_notify_transport }}://{% for host in masakari_oslomsg_notify_servers.split(',') %}{{ masakari_oslomsg_notify_userid }}:{{ masakari_oslomsg_notify_password }}@{{ host }}:{{ masakari_oslomsg_notify_port }}{% if not loop.last %},{% else %}/{{ _masakari_oslomsg_notify_vhost_conf }}{% if masakari_oslomsg_notify_use_ssl | bool %}?ssl=1&ssl_version={{ masakari_oslomsg_notify_ssl_version }}&ssl_ca_file={{ masakari_oslomsg_notify_ssl_ca_file }}{% else %}?ssl=0{% endif %}{% endif %}{% endfor %} diff --git a/vars/main.yml b/vars/main.yml index 3de86b9..4faed7c 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -18,6 +18,17 @@ _masakari_is_first_play_host: >- (masakari_services['masakari-api']['group'] in group_names and inventory_hostname == (groups[masakari_services['masakari-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }} +_masakari_oslomsg_rpc_vhost_conf: >- + {{ + (masakari_oslomsg_rpc_vhost is string) | ternary( + masakari_oslomsg_rpc_vhost, masakari_oslomsg_rpc_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} +_masakari_oslomsg_notify_vhost_conf: >- + {{ + (masakari_oslomsg_notify_vhost is string) | ternary( + masakari_oslomsg_notify_vhost, masakari_oslomsg_notify_vhost | selectattr('state', 'eq', 'present') | map(attribute='name') | first) + }} + masakari_pip_venv_packages: |- {% set pip_packages = [] %}