diff --git a/tasks/galera_install.yml b/tasks/galera_install.yml index 40085d8a..9a820420 100644 --- a/tasks/galera_install.yml +++ b/tasks/galera_install.yml @@ -33,11 +33,6 @@ when: - ansible_architecture == 'ppc64le' -- name: Remove conflicting distro packages - package: - name: "{{ galera_server_mariadb_distro_packages_remove | default([]) }}" - state: absent - - include_tasks: "galera_install_{{ ansible_pkg_mgr }}.yml" - name: Record galera has been deployed diff --git a/tasks/galera_install_apt.yml b/tasks/galera_install_apt.yml index 76e1c428..b9573056 100644 --- a/tasks/galera_install_apt.yml +++ b/tasks/galera_install_apt.yml @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Remove conflicting distro packages + package: + name: "{{ galera_server_mariadb_distro_packages_remove | default([]) }}" + state: absent + - name: If a keyfile is provided, copy the gpg keyfile to the key location copy: src: "{{ item.keyfile }}" diff --git a/tasks/galera_install_yum.yml b/tasks/galera_install_yum.yml index 38567547..2454afca 100644 --- a/tasks/galera_install_yum.yml +++ b/tasks/galera_install_yum.yml @@ -13,6 +13,29 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Unfortunately yum is case-insensitive, and RDO has mariadb-* packages, +# while the MariaDB repo has MariaDB-* packages and they conflict. +# To work around this we have to query for any installed RDO/CentOS +# packages using rpm, then remove them. We have to remove them without +# dependencies, otherwise for distro package installation types on shared +# hosts it removes far too many packages. +- name: Remove conflicting packages + shell: | + exit_code=0 + for pkg in {{ galera_server_mariadb_distro_packages_remove | join(' ') }}; do + if rpm --query --quiet ${pkg}; then + rpm -ev --nodeps ${pkg} + exit_code=2 + fi + done + exit ${exit_code} + register: _remove_existing_mariadb_packages + changed_when: _remove_existing_mariadb_packages.rc == 2 + failed_when: _remove_existing_mariadb_packages.rc not in [0, 2] + args: + warn: no + executable: /bin/bash + - name: Update the local file system CRUD file: src: "{{ item.src|default(omit) }}" diff --git a/tasks/galera_install_zypper.yml b/tasks/galera_install_zypper.yml index 639bc24a..3040fe50 100644 --- a/tasks/galera_install_zypper.yml +++ b/tasks/galera_install_zypper.yml @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Remove conflicting distro packages + package: + name: "{{ galera_server_mariadb_distro_packages_remove }}" + state: absent + - name: Update the local file system CRUD file: src: "{{ item.src|default(omit) }}" diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index a4cfc2c1..5994fcff 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -54,6 +54,12 @@ galera_server_mariadb_distro_packages: - rsync - socat +# Conflicting packages with those from the MariaDB repository +galera_server_mariadb_distro_packages_remove: + - mariadb-common + - mariadb-config + - mariadb-server + # The packages to uninstall during an upgrade from a previous version galera_server_upgrade_packages_remove: - MariaDB-Galera-server