Upgrading packages on Debian platform family fails
Hi,
When upgrading packages (in my case I only use Kafka) on Debian platform family (I use Ubuntu), installation fails because the default configuration files that are included in the package are overwritten with non-default values.
So you get an error like this
================================================================================
Error executing action `install` on resource 'apt_package[confluent-kafka]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '100'
---- Begin output of ["apt-get", "-q", "-y", "install", "confluent-kafka=6.1.1-1"] ----
STDOUT: Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
confluent-kafka-2.11
The following NEW packages will be installed:
confluent-kafka
0 upgraded, 1 newly installed, 1 to remove and 22 not upgraded.
Need to get 64.1 MB of archives.
After this operation, 6521 kB disk space will be freed.
Get:1 http://packages.confluent.io/deb/6.1 stable/main amd64 confluent-kafka all 6.1.1-1 [64.1 MB]
Fetched 64.1 MB in 1s (35.9 MB/s)
(Reading database ... 73441 files and directories currently installed.)
Removing confluent-kafka-2.11 (5.4.3-1) ...
Selecting previously unselected package confluent-kafka.
(Reading database ... 73297 files and directories currently installed.)
Preparing to unpack .../confluent-kafka_6.1.1-1_all.deb ...
Unpacking confluent-kafka (6.1.1-1) ...
Setting up confluent-kafka (6.1.1-1) ...
Configuration file '/etc/kafka/log4j.properties'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** log4j.properties (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing package confluent-kafka (--configure):
end of file on stdin at conffile prompt
Errors were encountered while processing:
confluent-kafka
STDERR: E: Sub-process /usr/bin/dpkg returned an error code (1)
---- End output of ["apt-get", "-q", "-y", "install", "confluent-kafka=6.1.1-1"] ----
Ran ["apt-get", "-q", "-y", "install", "confluent-kafka=6.1.1-1"] returned 100
Resource Declaration:
---------------------
# In /var/cache/chef/cookbooks/confluent-platform/recipes/kafka_package.rb
28: package pkg_name do
29: retries package_retries unless package_retries.nil?
30: version pkg_version unless pkg_version.nil? || pkg_version == 'latest'
31: action :upgrade if pkg_version == 'latest'
32: end
Compiled Resource:
------------------
# Declared in /var/cache/chef/cookbooks/confluent-platform/recipes/kafka_package.rb:28:in `from_file'
apt_package("confluent-kafka") do
package_name "confluent-kafka"
action [:install]
default_guard_interpreter :default
declared_type :package
cookbook_name "confluent-platform"
recipe_name "kafka_package"
end
System Info:
------------
chef_version=13.12.14
platform=ubuntu
platform_version=16.04
ruby=ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
program_name=chef-client worker: ppid=17367;start=14:06:31;
executable=/opt/chef/bin/chef-client
A simple fix would be to specify so apt uses the "old" config, i.e. the one on disk. This can be achieved by adding something like the options
line below.
Also node['platform_family'] == 'debian'
takes all debian forks into account.
package pkg_name do
retries package_retries unless package_retries.nil?
version pkg_version unless pkg_version.nil? || pkg_version == 'latest'
options '-o Dpkg::Options::="--force-confold"' if node['platform_family'] == 'debian'
action :upgrade if pkg_version == 'latest'
end
I do not know how this works for RPM based platforms, but this solution covers debian based platforms without breaking anything for other platforms.
(Update: fix typo s/package_options/options/)
Edited by Elias Abacioglu