Use the utility host for db setup tasks

Move it to the service setup host (defaults to utility[0]) instead
of the galera[0] host, and use galera_address (defaults to internal VIP)
as the endpoint instead of a local connection on the db host.

Change-Id: I1171b6a45563e4eccf45e8840e5dd332001ff3b7
This commit is contained in:
Jonathan Rosser 2020-09-28 15:38:13 +01:00
parent f6f96e8b9c
commit d4e570e47b
3 changed files with 12 additions and 0 deletions

View File

@ -53,6 +53,8 @@ aodh_system_comment: aodh system user
aodh_system_user_home: "/var/lib/{{ aodh_system_user_name }}"
## Database info
aodh_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}"
aodh_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((aodh_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}"
aodh_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}"
aodh_db_address: "{{ galera_address | default('127.0.0.1') }}"
aodh_database_name: aodh
@ -61,6 +63,7 @@ aodh_db_type: "mysql+pymysql"
aodh_galera_use_ssl: "{{ galera_use_ssl | default(False) }}"
aodh_galera_ssl_ca_cert: "{{ galera_ssl_ca_cert | default('/etc/ssl/certs/galera-ca.pem') }}"
aodh_connection_string: "{{ aodh_db_type }}://{{ aodh_database_user }}:{{ aodh_container_db_password }}@{{ aodh_db_address }}/{{ aodh_database_name }}?charset=utf8{% if aodh_galera_use_ssl | bool %}&ssl_ca={{ aodh_galera_ssl_ca_cert }}{% endif %}"
aodh_galera_port: 3306
# Oslo Messaging
# RPC

View File

@ -22,12 +22,16 @@
- name: Setup Database Service (MariaDB)
delegate_to: "{{ _oslodb_setup_host }}"
vars:
ansible_python_interpreter: "{{ _oslodb_ansible_python_interpreter }}"
tags:
- common-mariadb
block:
- name: Create database for service
mysql_db:
name: "{{ item.name }}"
login_host: "{{ _oslodb_setup_endpoint | default(omit) }}"
login_port: "{{ _oslodb_setup_port | default(omit) }}"
loop: "{{ _oslodb_databases }}"
no_log: true
@ -38,5 +42,7 @@
host: "{{ item.1.host | default('%') }}"
priv: "{{ item.0.name }}.*:{{ item.1.priv | default('ALL') }}"
append_privs: yes
login_host: "{{ _oslodb_setup_endpoint | default(omit) }}"
login_port: "{{ _oslodb_setup_port | default(omit) }}"
loop: "{{ _oslodb_databases | subelements('users') }}"
no_log: true

View File

@ -52,6 +52,9 @@
- _aodh_is_first_play_host
vars:
_oslodb_setup_host: "{{ aodh_db_setup_host }}"
_oslodb_ansible_python_interpreter: "{{ aodh_db_setup_python_interpreter }}"
_oslodb_setup_endpoint: "{{ aodh_galera_address }}"
_oslodb_setup_port: "{{ aodh_galera_port }}"
_oslodb_databases:
- name: "{{ aodh_database_name }}"
users: