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: I0bd9a36b69fb2eb388b0e23ed1fb52644d7ba4bc
This commit is contained in:
Dmitriy Rabotyagov 2020-08-20 19:30:54 +03:00
parent 40bc580522
commit 7fb7f1ba75
3 changed files with 12 additions and 1 deletions

View File

@ -68,7 +68,8 @@ octavia_auth_strategy: keystone
octavia_cinder_enabled: False octavia_cinder_enabled: False
## Database info ## Database info
octavia_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" octavia_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}"
octavia_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((octavia_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}"
octavia_galera_address: "{{ galera_address | default('127.0.0.1') }}" octavia_galera_address: "{{ galera_address | default('127.0.0.1') }}"
octavia_galera_user: octavia octavia_galera_user: octavia
octavia_galera_database: octavia octavia_galera_database: octavia
@ -77,6 +78,7 @@ octavia_galera_ssl_ca_cert: "{{ galera_ssl_ca_cert | default('/etc/ssl/certs/gal
octavia_db_max_overflow: 20 octavia_db_max_overflow: 20
octavia_db_pool_size: 120 octavia_db_pool_size: 120
octavia_db_pool_timeout: 30 octavia_db_pool_timeout: 30
octavia_galera_port: 3306
## Oslo Messaging ## Oslo Messaging

View File

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

View File

@ -47,6 +47,9 @@
- inventory_hostname == groups['octavia_all'][0] - inventory_hostname == groups['octavia_all'][0]
vars: vars:
_oslodb_setup_host: "{{ octavia_db_setup_host }}" _oslodb_setup_host: "{{ octavia_db_setup_host }}"
_oslodb_ansible_python_interpreter: "{{ octavia_db_setup_python_interpreter }}"
_oslodb_setup_endpoint: "{{ octavia_galera_address }}"
_oslodb_setup_port: "{{ octavia_galera_port }}"
_oslodb_databases: _oslodb_databases:
- name: "{{ octavia_galera_database }}" - name: "{{ octavia_galera_database }}"
users: users: