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
(cherry picked from commit 72f402d3e9)
This commit is contained in:
Jesse Pretorius 2018-09-17 20:25:02 +01:00 committed by Jesse Pretorius (odyssey4me)
parent ded63adefc
commit 943b0360a7
5 changed files with 39 additions and 5 deletions

View File

@ -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

View File

@ -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 }}"

View File

@ -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) }}"

View File

@ -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) }}"

View File

@ -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