问题原文
原帖链接 · David · CC BY-SA 4.0
I am trying to install the kernel-devel package matching the running kernel version.
My guess was:
package { 'kernel-devel':
ensure => "${facts['kernelrelease']}",
}
but it doesn't work if more than one kernel-devel package are already installed. This is the error I get:
Error: Could not update: Failed to update to version 3.10.0-957.21.3.el7.x86_64, got version 3.10.0-957.21.3.el7; 3.10.0-1062.4.3.el7; 3.10.0-1062.9.1.el7 instead
So the package is already installed, but the Package class raises an error because (apparently) it performs a string comparison instead of looking in the versions list.
What is the proper way to handle this?
已采纳解答
原帖链接 · Aaron Copley · CC BY-SA 4.0
Unless I am misunderstanding, you can solve this with the version in the resource title.
package { "kernel-devel-${facts['kernelrelease']}":
ensure => present,
}
Or, if you have other resources which depend on 'kernel-devel' you can use the name attribute.
package { 'kernel-devel':
name => "kernel-devel-${facts['kernelrelease']}",
ensure => present,
}
[root@aaron ~]# dnf list installed kernel-devel
Installed Packages
kernel-devel.x86_64 5.3.11-200.fc30 @updates
kernel-devel.x86_64 5.3.14-200.fc30 @updates
[root@aaron ~]# uname -a
Linux aaron 5.3.15-200.fc30.x86_64 #1 SMP Thu Dec 5 15:18:00 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@aaron ~]# puppet apply kernel-devel.pp
Notice: Compiled catalog for aaron.tsp in environment production in 0.54 seconds
Notice: /Stage[main]/Main/Package[kernel-devel-5.3.15-200.fc30.x86_64]/ensure: created
Notice: Applied catalog in 62.18 seconds
[root@aaron ~]# dnf list installed kernel-devel
Installed Packages
kernel-devel.x86_64 5.3.11-200.fc30 @updates
kernel-devel.x86_64 5.3.14-200.fc30 @updates
kernel-devel.x86_64 5.3.15-200.fc30 @updates
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
