Find the list of packages to remove using rpm

In https://review.openstack.org/603056 we tried to remove conflicting
packages from the target host before installing packages from MariaDB,
but that didn't work because the package specified didn't exist. The
name used was an attempt to remove a specific version of the package
to avoid yum always removing and reinstalling the same packages.

Unfortunately yum is case-insensitive, and CentOS/EPEL/RDO have
mariadb-* packages, while the MariaDB repo has MariaDB-* packages.
These packages conflict.

To work around yum's case insensitivity, we have to query for any
installed packages using rpm (which is case-sensitive) and remove them.

We have to remove them without dependencies, otherwise for distro
package installation types on shared hosts it removes far too many
packages.

Change-Id: Ide19d3c1b8b0f1e6aed2ea01f2f082e6a2cbb83a
This commit is contained in:
Jesse Pretorius 2018-09-17 19:28:37 +01:00
parent e74cdc2911
commit d1d4bf4ac7
3 changed files with 27 additions and 19 deletions

View File

@ -21,23 +21,6 @@
- install-yum
- install-zypper
- name: Remove conflicting packages
package:
name: "{{ galera_client_distro_remove_packages | default([]) }}"
state: "absent"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
register: install_packages
until: install_packages is success
retries: 5
delay: 2
when:
- galera_client_package_install | bool
tags:
- galera-client-apt-packages
- galera-client-yum-packages
- galera-client-zypper-packages
- name: Install galera distro packages
package:
name: "{{ galera_client_distro_packages }}"

View File

@ -13,7 +13,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Stats /etc/my.cnf.d
# 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_client_distro_remove_packages | 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: Stat /etc/my.cnf.d
stat:
path: /etc/my.cnf.d
register: mycnfd_stat

View File

@ -23,8 +23,10 @@ _galera_client_repo:
gpgkey: "http://yum.mariadb.org/RPM-GPG-KEY-MariaDB"
# Packages conflicting with MariaDB
# These are evaluated using case-sensitivity!
galera_client_distro_remove_packages:
- mariadb-common-3
- mariadb-common
- mariadb-config
# MariaDB-devel is required for mysql_config, which is subsequently required for pip install of MySQL-python
galera_client_distro_packages: