commit 948374ddf0c0dafd8f6e18b116df97f2e0966f25 Author: Jonathan Rosser Date: Mon Sep 28 15:43:44 2020 +0100 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. Depends-On: https://review.opendev.org/754718 Depends-On: https://review.opendev.org/755258 Change-Id: I5098673bdf84d1c2b13ca87e474a5c598260ae94 diff --git a/defaults/main.yml b/defaults/main.yml index 49da779..9faf4d4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -70,6 +70,8 @@ gnocchi_venv_pkgs: "/openstack/venvs/gnocchi-{{ gnocchi_venv_tag }}/lib/python2. gnocchi_etc_dir: "{{ gnocchi_bin | dirname }}/etc/gnocchi" #: Index Database info +gnocchi_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}" +gnocchi_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((gnocchi_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" gnocchi_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" gnocchi_galera_address: "{{ galera_address | default('127.0.0.1') }}" gnocchi_galera_database: gnocchi @@ -77,6 +79,7 @@ gnocchi_galera_user: gnocchi gnocchi_db_sync_options: "" gnocchi_galera_use_ssl: "{{ galera_use_ssl | default(False) }}" gnocchi_galera_ssl_ca_cert: "{{ galera_ssl_ca_cert | default('/etc/ssl/certs/galera-ca.pem') }}" +gnocchi_galera_port: 3306 #: Storage info gnocchi_storage_driver: file @@ -86,7 +89,7 @@ gnocchi_coordination_url: "mysql://{{ gnocchi_galera_user }}:{{ gnocchi_containe gnocchi_ceph_pool: "metrics" gnocchi_ceph_username: "gnocchi" -#: System info +#a System info gnocchi_system_user_name: gnocchi gnocchi_system_group_name: gnocchi gnocchi_system_shell: /bin/false diff --git a/tasks/db_setup.yml b/tasks/db_setup.yml index 7a0120d..aca206e 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 bbc7276..8caeb9d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -30,6 +30,9 @@ - _gnocchi_is_first_play_host vars: _oslodb_setup_host: "{{ gnocchi_db_setup_host }}" + _oslodb_ansible_python_interpreter: "{{ gnocchi_db_setup_python_interpreter }}" + _oslodb_setup_endpoint: "{{ gnocchi_galera_address }}" + _oslodb_setup_port: "{{ gnocchi_galera_port }}" _oslodb_databases: - name: "{{ gnocchi_galera_database }}" users: