From 72f402d3e969c94754ade02953d2c94ce541b25e Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 17 Sep 2018 20:25:02 +0100 Subject: [PATCH] Revisit conflicting package removal In https://review.openstack.org/534819 we introduced the removal of conflicting packages from the targeted host, but then we deleted the list for RedHat in https://review.openstack.org/578844 because yum kept removing and re-adding the same packages. In https://review.openstack.org/603205 we solve the issue properly given that yum is case-insensitive, and the root cause of the repeat remove/install. As such, in this patch, we restore the removal of conflicting packages for RedHat in a different way. Each of the package removal tasks are moved into the tasks specific to each package manager so that each can be handled differently. Change-Id: I70fbfa6eff8796713c6bec32319382273f8281f8 Related-Bug: #1762421 Related-Bug: #1742206 --- tasks/galera_install.yml | 5 ----- tasks/galera_install_apt.yml | 5 +++++ tasks/galera_install_yum.yml | 23 +++++++++++++++++++++++ tasks/galera_install_zypper.yml | 5 +++++ vars/redhat-7.yml | 6 ++++++ 5 files changed, 39 insertions(+), 5 deletions(-) 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