Fix creation of prometheus user and grant permissions

Prometheus is creating user and granting permissions
to database from which is gathering metrics. This
process is different when haproxy/proxysql is used.

Proxysql:

  - kolla-ansible should use root_shard_ID user to connect
    to ProxySQL endpoint and it is routed to proper shard.

Haproxy:

  - kolla-ansible should use root user to connect to HAProxy
    endpoint and that's all.

If proxysql is not used, mariadb role will not create user
shard_root_ID user in bootstrap (from my perspective of view
it should), and therefore it will fail when HAProxy is used.

This patch is just fixing user to connect.

Change-Id: Icd07807b2c404eb4d3f398879639b17f1e7949c2
This commit is contained in:
Michal Arbet 2022-08-30 14:56:48 +02:00
parent 37d9cf0d19
commit c5500bdfd2

View File

@ -3,7 +3,7 @@
become: true
vars:
shard_id: "{{ item.key }}"
shard_root_user: "{{ mariadb_shard_root_user_prefix }}{{ shard_id | string }}"
shard_root_user: "{% if mariadb_loadbalancer == 'haproxy' %}{{ database_user }}{% else %}{{ mariadb_shard_root_user_prefix }}{{ shard_id | string }}{% endif %}"
shard_host: "{{ mariadb_shards_info.shards[shard_id].hosts[0] }}"
kolla_toolbox:
module_name: mysql_user
@ -22,6 +22,5 @@
label: "{{ shard_host }}"
run_once: True
when:
- inventory_hostname == groups['prometheus'][0]
- enable_prometheus_mysqld_exporter | bool
- not use_preconfigured_databases | bool