From 6cbb5cbdb4e6cc0847721af57048b5a14238f09a Mon Sep 17 00:00:00 2001 From: Doug Szumski Date: Mon, 22 Oct 2018 12:24:20 +0000 Subject: [PATCH] Support using external DBs in Monasca This changes allows the user to configure a Monasca database which may be different from the default database. Partially-Implements: blueprint monasca-roles Change-Id: Ia905190b8037ecb1782a758c0b65581fe9024bf6 --- ansible/roles/monasca/defaults/main.yml | 3 ++- ansible/roles/monasca/tasks/bootstrap.yml | 8 ++++---- ansible/roles/monasca/templates/monasca-api/api.conf.j2 | 2 +- .../templates/monasca-notification/notification.conf.j2 | 4 ++-- .../monasca/templates/monasca-thresh/thresh-config.yml.j2 | 6 +++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ansible/roles/monasca/defaults/main.yml b/ansible/roles/monasca/defaults/main.yml index ab335ac4d5..3ecbea78e5 100644 --- a/ansible/roles/monasca/defaults/main.yml +++ b/ansible/roles/monasca/defaults/main.yml @@ -144,7 +144,8 @@ monasca_services: #################### monasca_database_name: "monasca" monasca_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}monasca{% endif %}" -monasca_database_address: "{{ database_address }}:{{ database_port }}" +monasca_database_address: "{{ database_address }}" +monasca_database_port: "{{ database_port }}" monasca_influxdb_name: "monasca" monasca_influxdb_address: "{{ kolla_internal_fqdn }}" diff --git a/ansible/roles/monasca/tasks/bootstrap.yml b/ansible/roles/monasca/tasks/bootstrap.yml index c298ff7da1..0e9d437152 100644 --- a/ansible/roles/monasca/tasks/bootstrap.yml +++ b/ansible/roles/monasca/tasks/bootstrap.yml @@ -3,8 +3,8 @@ kolla_toolbox: module_name: mysql_db module_args: - login_host: "{{ database_address }}" - login_port: "{{ database_port }}" + login_host: "{{ monasca_database_address }}" + login_port: "{{ monasca_database_port }}" login_user: "{{ database_user }}" login_password: "{{ database_password }}" name: "{{ monasca_database_name }}" @@ -18,8 +18,8 @@ kolla_toolbox: module_name: mysql_user module_args: - login_host: "{{ database_address }}" - login_port: "{{ database_port }}" + login_host: "{{ monasca_database_address }}" + login_port: "{{ monasca_database_port }}" login_user: "{{ database_user }}" login_password: "{{ database_password }}" name: "{{ monasca_database_user }}" diff --git a/ansible/roles/monasca/templates/monasca-api/api.conf.j2 b/ansible/roles/monasca/templates/monasca-api/api.conf.j2 index d31b83b5ac..436828bbd5 100644 --- a/ansible/roles/monasca/templates/monasca-api/api.conf.j2 +++ b/ansible/roles/monasca/templates/monasca-api/api.conf.j2 @@ -6,7 +6,7 @@ region = {{ openstack_region_name }} [database] database = {{ monasca_database_name }} -connection = mysql+pymysql://{{ monasca_database_user }}:{{ monasca_database_password }}@{{ monasca_database_address }}/{{ monasca_database_name }} +connection = mysql+pymysql://{{ monasca_database_user }}:{{ monasca_database_password }}@{{ monasca_database_address }}:{{ monasca_database_port }}/{{ monasca_database_name }} [influxdb] database_name = {{ monasca_influxdb_name }} diff --git a/ansible/roles/monasca/templates/monasca-notification/notification.conf.j2 b/ansible/roles/monasca/templates/monasca-notification/notification.conf.j2 index 9e7d7d3b80..c1675a77d9 100644 --- a/ansible/roles/monasca/templates/monasca-notification/notification.conf.j2 +++ b/ansible/roles/monasca/templates/monasca-notification/notification.conf.j2 @@ -11,8 +11,8 @@ notification_retry_topic = {{ monasca_alarm_notifications_retry_topic }} periodic = {{ monasca_periodic_notifications_period }}:{{ monasca_periodic_notifications_topic }} [mysql] -host = {{ database_address }} -port = {{ database_port }} +host = {{ monasca_database_address }} +port = {{ monasca_database_port }} user = {{ monasca_database_user }} passwd = {{ monasca_database_password }} db = {{ monasca_database_name }} diff --git a/ansible/roles/monasca/templates/monasca-thresh/thresh-config.yml.j2 b/ansible/roles/monasca/templates/monasca-thresh/thresh-config.yml.j2 index 7a35efa9fe..01b80f772f 100644 --- a/ansible/roles/monasca/templates/monasca-thresh/thresh-config.yml.j2 +++ b/ansible/roles/monasca/templates/monasca-thresh/thresh-config.yml.j2 @@ -109,7 +109,7 @@ sporadicMetricNamespaces: database: driverClass: org.drizzle.jdbc.DrizzleDriver - url: "jdbc:drizzle://{{ monasca_database_address }}/{{ monasca_database_name }}" + url: "jdbc:drizzle://{{ monasca_database_address }}:{{ monasca_database_port }}/{{ monasca_database_name }}" user: "{{ monasca_database_user }}" password: "{{ monasca_database_password }}" properties: @@ -126,7 +126,7 @@ database: # hibernate provider class providerClass: com.zaxxer.hikari.hibernate.HikariConnectionProvider databaseName: "{{ monasca_database_name }}" - serverName: "{{ database_address }}" - portNumber: "{{ database_port }}" + serverName: "{{ monasca_database_address }}" + portNumber: "{{ monasca_database_port }}" # hibernate auto configuration parameter autoConfig: validate