如何获取 Chef 食谱的最新 java 包 name/version?
How to get latest java package name/version for Chef recipe?
我想收集 yum 频道中可用的最新 java 版本。这样我就可以通知客户是否愿意进行升级。在这种情况下,他们将在任何更改之前使用 Chef 包升级功能知道将使用哪个版本。
解决方法:
您可以使用 Ohai 插件通过执行与此类似的命令并将其存储为属性来获取它:
root@servername DEV # yum list all jre1.*[5,6,7,8,9].* | tail -n 1
jre1.8.0_72.x86_64 1.8.0_72-fcs repositoryname
root@servername DEV #
这在一个线程中进行了讨论,我确认它有效。
How to find out version of software package installed on the node?
我正在寻找简化它或尽可能使其更优雅的方法。
基本上,问题是 yum upgrade/Chef package upgrade?
会安装什么版本
使用 shell_out
应该适合您的用例,即使我并没有真正实现所有这些的最终目标。
node.set['whaterver']['attribute'] = shell_out("yum list all jre1.*[5,6,7,8,9].* | tail -n 1 | cut -f 2").stdout.strip
文档是 here。 Recipe DSL shell_out
是一个包装器,它的工作方式类似于 Mixin::ShellOut.new
并进行了一些健全性检查。
我想收集 yum 频道中可用的最新 java 版本。这样我就可以通知客户是否愿意进行升级。在这种情况下,他们将在任何更改之前使用 Chef 包升级功能知道将使用哪个版本。
解决方法: 您可以使用 Ohai 插件通过执行与此类似的命令并将其存储为属性来获取它:
root@servername DEV # yum list all jre1.*[5,6,7,8,9].* | tail -n 1
jre1.8.0_72.x86_64 1.8.0_72-fcs repositoryname
root@servername DEV #
这在一个线程中进行了讨论,我确认它有效。 How to find out version of software package installed on the node?
我正在寻找简化它或尽可能使其更优雅的方法。 基本上,问题是 yum upgrade/Chef package upgrade?
会安装什么版本使用 shell_out
应该适合您的用例,即使我并没有真正实现所有这些的最终目标。
node.set['whaterver']['attribute'] = shell_out("yum list all jre1.*[5,6,7,8,9].* | tail -n 1 | cut -f 2").stdout.strip
文档是 here。 Recipe DSL shell_out
是一个包装器,它的工作方式类似于 Mixin::ShellOut.new
并进行了一些健全性检查。