Skip to content

Commit

Permalink
Mariadb version bump and check (#174)
Browse files Browse the repository at this point in the history
* Bump the default mariadb_version to 10.11
* Drop hardcoded version in debian-12
* Set default mariadb_upgrade: false
* Implement a mariadb_version check
  • Loading branch information
kwizart authored Sep 4, 2023
1 parent ec86b4b commit 293fbf6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
7 changes: 6 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# MariaDB setting

# Define mariadb version
mariadb_version: "10.6"
mariadb_version: "10.11"

# Defines if we should enable the MariaDB repo or use version within OS repos.
galera_enable_mariadb_repo: true
Expand Down Expand Up @@ -85,6 +85,11 @@ mariadb_charset_client: "utf8"
# mariadb:
# max_connections: 2048

# Defines if mariadb is already available on the target hosts
# It will compare version between ansible and system and exit early if missmatch
# This prevent unexpected change on role upgrade
mariadb_upgrade: false

# Galera settings

# Defines if the galera cluster should be reconfigured
Expand Down
37 changes: 37 additions & 0 deletions tasks/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,40 @@
tags:
- install
- config

- name: Check mariadb_version on target system
command: "mariadb -V"
check_mode: false
register: mariadb_version_check
failed_when: '"mariadb" not in mariadb_version_check.stdout and mariadb_version_check.rc == 0'
changed_when: not 'mariadb_version_check.rc == 0'
when: not mariadb_upgrade|bool
tags:
- install
- config

- name: Extract MariaDB version
set_fact:
mariadb_version_checked: "{{ mariadb_version_check.stdout.split(' ')[5] }}"
check_mode: false
when: not mariadb_upgrade|bool and mariadb_version_check.rc == 0
tags:
- install
- config

- name:
debug:
msg: "Installed {{ mariadb_version_checked }} - mariadb_version: {{ mariadb_version }}"
when: not mariadb_upgrade|bool and mariadb_version_check.rc == 0

- name: Verify the expected mariadb_version
assert:
that: 'mariadb_version_checked.startswith("{{ mariadb_version }}")'
fail_msg: >-
The mariadb_version "{{ mariadb_version }}" doesn't match the one
installed on the system: {{ mariadb_version_checked }}.
Use the correct mariadb_version or set mariadb_upgrade: True
when: not mariadb_upgrade|bool and mariadb_version_check.rc == 0
tags:
- install
- config
1 change: 0 additions & 1 deletion vars/debian-12.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
mariadb_version: "10.11"
mariadb_login_unix_socket: "/var/run/mysqld/mysqld.sock"
mariadb_pre_req_packages:
- "apt-transport-https"
Expand Down

1 comment on commit 293fbf6

@elcomtik
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwizart This seems not necessary, because when i enabled upgrades the actual upgrade failed on packege upgrade due to chceck that are buolt in packages. The proper way to do major uprade is to backup(dump), then uninstall package a install new one. I'm thinking about steps necessary for doing this by this role, hovewer thi is currently not supported.

Please sign in to comment.