From 9a5cbb3dfce961cf253770c42098b854c95d4c09 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 20 Aug 2020 18:20:08 +0300 Subject: [PATCH] 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: I87d61c619920a945c7a0b0887e3902f39f2b1b3c --- defaults/main.yml | 12 ++++++++---- tasks/db_setup.yml | 6 ++++++ tasks/main.yml | 6 ++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 07fa4806..d4285309 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -139,12 +139,14 @@ ironic_automated_clean: false ironic_erase_devices_priority: 10 # Database -ironic_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" +ironic_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}" +ironic_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((ironic_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" ironic_galera_address: "{{ galera_address | default('127.0.0.1') }}" ironic_galera_user: ironic ironic_galera_database: ironic ironic_galera_use_ssl: "{{ galera_use_ssl | default(False) }}" ironic_galera_ssl_ca_cert: "{{ galera_ssl_ca_cert | default('/etc/ssl/certs/galera-ca.pem') }}" +ironic_galera_port: 3306 ## Keystone authentication middleware ironic_keystone_auth_plugin: password @@ -164,7 +166,7 @@ ironic_default_network_interface: "{{ (ironic_neutron_provisioning_network_uuid ironic_auth_strategy: keystone ironic_dhcp_provider: "{{ (ironic_standalone | bool) | ternary('none', 'neutron') }}" ironic_sync_power_state_interval: "{{ (ironic_standalone | bool) | ternary('-1', '60') }}" -ironic_db_connection_string: "mysql+pymysql://{{ ironic_galera_user }}:{{ ironic_container_mysql_password }}@{{ ironic_galera_address }}/ironic{% if ironic_galera_use_ssl | bool %}&ssl_ca={{ ironic_galera_ssl_ca_cert }}{% endif %}" +ironic_db_connection_string: "mysql+pymysql://{{ ironic_galera_user }}:{{ ironic_container_mysql_password }}@{{ ironic_galera_address }}:{{ ironic_galera_port }}/ironic{% if ironic_galera_use_ssl | bool %}&ssl_ca={{ ironic_galera_ssl_ca_cert }}{% endif %}" # Ironic db tuning ironic_db_max_overflow: 10 @@ -301,10 +303,12 @@ ironic_inspector_service_in_ldap: False ironic_inspector_service_domain_id: default # Database -ironic_inspector_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" +ironic_inspector_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}" +ironic_inspector_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((ironic_inspector_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" ironic_inspector_galera_address: "{{ galera_address | default('127.0.0.1') }}" ironic_inspector_galera_user: ironic-inspector ironic_inspector_galera_database: ironic_inspector +ironic_inspector_galera_port: 3306 # Ironic db tuning ironic_inspector_db_max_overflow: 10 @@ -326,7 +330,7 @@ ironic_inspector_swift_role_names: # Ironic inspector ironic_inspector_enable_discovery: True -ironic_inspector_openstack_db_connection_string: "mysql+pymysql://{{ ironic_inspector_galera_user }}:{{ ironic_inspector_container_mysql_password }}@{{ ironic_inspector_galera_address }}/{{ ironic_inspector_galera_database }}" +ironic_inspector_openstack_db_connection_string: "mysql+pymysql://{{ ironic_inspector_galera_user }}:{{ ironic_inspector_container_mysql_password }}@{{ ironic_inspector_galera_address }}:{{ ironic_inspector_galera_port }}/{{ ironic_inspector_galera_database }}" # Ironic inspector dhcp ironic_inspector_dhcp_pool_range: 192.168.0.51 192.168.0.150 diff --git a/tasks/db_setup.yml b/tasks/db_setup.yml index 7a0120d4..aca206e4 100644 --- a/tasks/db_setup.yml +++ b/tasks/db_setup.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 05e64dd2..a850232b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -30,6 +30,9 @@ - "inventory_hostname == ((groups[ironic_services['ironic-api']['group']]| intersect(ansible_play_hosts)) | list)[0]" vars: _oslodb_setup_host: "{{ ironic_db_setup_host }}" + _oslodb_ansible_python_interpreter: "{{ ironic_db_setup_python_interpreter }}" + _oslodb_setup_endpoint: "{{ ironic_galera_address }}" + _oslodb_setup_port: "{{ ironic_galera_port }}" _oslodb_databases: - name: "{{ ironic_galera_database }}" users: @@ -45,6 +48,9 @@ - "inventory_hostname == ((groups[ironic_services['ironic-inspector']['group']]| intersect(ansible_play_hosts)) | list)[0]" vars: _oslodb_setup_host: "{{ ironic_inspector_db_setup_host }}" + _oslodb_ansible_python_interpreter: "{{ ironic_inspector_db_setup_python_interpreter }}" + _oslodb_setup_endpoint: "{{ ironic_inspector_galera_address }}" + _oslodb_setup_port: "{{ ironic_inspector_galera_port }}" _oslodb_databases: - name: "{{ ironic_inspector_galera_database }}" users: