Skip to content

Instantly share code, notes, and snippets.

@jsmartt
Created February 3, 2017 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsmartt/010c73edac388560e82ad14d7dc78f8c to your computer and use it in GitHub Desktop.
Save jsmartt/010c73edac388560e82ad14d7dc78f8c to your computer and use it in GitHub Desktop.
#
# Cookbook Name:: test_package
# Recipe:: default
#
# This recipe is meant to show the issues with the package resource, specifically
# using Yum, where multiple packages need to be installed/updated at once. It was
# executed with Kitchen-vagrant with the "centos-7.2" platform name. Nothing fancy.
# Make sure my yum cache is clean. Gets around some 404 errors for old mirrors.
execute 'yum clean all'
# Let's say we're starting out with an outdated version of the libstdc++ package.
# In my Kitchen-vagrant VM (centos-7.2), it comes with libstdc++-4.8.5-4.x86_64
# (no 32-bit version). However, this same case should work if the 32-bit package
# was installed (at that same 4.8.5-4 version. The problem is that when I try to
# update either package, it complains saying that the other package needs the same
# version. i.e., I need to do both at once. However, the package resource fails
# miserably with an array of package_names and/or package_names with the architecture
# concatenated on the end. Observe.
# This doesn't actually do anything, just proves that it has this version installed.
# This resource executes as it should (no action needed)
package 'libstdc++.x86_64' do
version '4.8.5-4.el7' # Old version that came with the vagrant box
end
# But let's say I want to make sure I have both the 32-bit and 64-bit versions of this
# package installed and at a certain version (newer than my current version)
# When I try to do this, it completely ignores the 32-bit version and only installs
# the 64-bit package, although it does install this version of it. Bug!
package ['libstdc++.x86_64', 'libstdc++.i686'] do
version '4.8.5-11.el7' # Updated version
end
# I've tried a bunch of different ways to try to get this to work, but none seem to work.
# Here's a list of failed examples:
# This one fails with " No candidate version available for libstdc++". See chef issue
# 4266: https://github.com/chef/chef/issues/4266. Bug!
package 'libstdc++' do
arch ['x86_64', 'i686']
version '4.8.5-11.el7' # Updated version
end
# In the comments of issue 4266 a Chef employee says to do this, but this also fails. The
# message is "No candidate version available for libstdc++, libstdc++". Bug!
package ['libstdc++', 'libstdc++'] do
arch ['x86_64', 'i686']
version '4.8.5-11.el7' # Updated version
end
# To my knowledge, those are the only options I have to install these packages at the same
# time using the package or yum_package resource. As a last resort let's try to install
# them seperately with individual resources. This also fails, because Multilib requires
# these 2 packages to be at the same version. The error is: "Protected multilib versions:
# libstdc++-4.8.5-11.el7.i686 != libstdc++-4.8.5-4.el7.x86_64"
package 'libstdc++.i686' do
version '4.8.5-11.el7' # Updated version
end
package 'libstdc++.x86_64' do
version '4.8.5-11.el7' # Updated version
end
# Now, I can switch the resources so that the 64-bit package is installed first. Since the
# 32-bit package isn't installed yet, it is happy to upgrade the 64-bit package, then install
# the same version of the 32-bit package. But that only works once, so my problem is definitely
# not solved. I need both to install together to make Multilib happy, but the package resource
# provides me no working way to do that.
# In addition, the following does not work. It tries to remove the x86_64 architecture instead. Bug!
package 'libstdc++.i686' do
action :remove
end
# This, however, does work properly:
package 'libstdc++' do
arch 'i686'
action :remove
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment