openstack-ansible-galera_se.../tasks/galera_server_setup.yml
Andrew Bonney 5200b50cf6 Add the ability to specify custom additional galera users
This provides the capability to add and remove additional users
in the Galera database which may be used by external resource
monitoring systems (for example).

The Ansible mysql 'resource_limits' variable is also exposed to
enable setting connection limits against individual users.

Change-Id: Idcc9251340215baf5e6f550a9ca844c8c097d353
2022-09-12 13:24:37 +01:00

50 lines
1.7 KiB
YAML

---
# Copyright 2014, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Run mysql_upgrade
block:
- name: Fail if upgrade is needed
command: /usr/bin/mariadb-upgrade --check-if-upgrade-is-needed
register: galera_upgrade_check
failed_when: galera_upgrade_check.rc == 0
changed_when: False
rescue:
- name: Run MySQL Upgrade
command: /usr/bin/mariadb-upgrade
register: galera_mysql_upgrade
changed_when:
- not galera_mysql_upgrade.stdout is search("already upgraded")
until: galera_mysql_upgrade is success
retries: 3
delay: 10
# NOTE(noonedeadpunk): We don't need to verify hostname when connectig to socket
- name: Create galera users
community.mysql.mysql_user:
name: "{{ item.name }}"
host: "{{ item.host }}"
password: "{{ item.password }}"
priv: "{{ item.priv }}"
state: "{{ item.state }}"
resource_limits: "{{ item.resource_limits | default(omit) }}"
login_unix_socket: "{{ galera_unix_socket }}"
check_hostname: false
with_items: "{{ galera_setup_users }}"
register: galera_users
until: galera_users is success
retries: 3
delay: 10
no_log: True