厨师执行期间在原生扩展包后安装gem [英] Installing a gem after native extension packages during chef execution

查看:111
本文介绍了厨师执行期间在原生扩展包后安装gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在厨师配方中安装雾宝石,但是在安装本地软件包之前发生了gem安装,因此gem安装失败。

  packagelibxslt-dev
packagelibxml2-dev

chef_gemfog

这是输出

  [Thu,2013年3月14日13:04 :30 +0000] INFO:处理chef_gem [雾]行动安装(ebs4000 :: update_volumes行23)
[Thu,2013年3月14日13:04:52 +0000]错误:运行异常处理程序
[星期四,14 Mar 2013 13:04:52 +0000]致命:将节点信息保存到/var/cache/chef/failed-run-data.json
[Thu,2013年3月14日13:04:52 +0000 ]错误:异常处理完成
[Thu,2013年3月14日13:04:52 +0000]错误:Gem :: Installer :: ExtensionBuildError:chef_gem [fog](cookbook :: recipe line 4)出现错误: Gem :: Installer :: ExtensionBuildError:错误:无法构建gem本机扩展。

/usr/bin/ruby1.8 extconf.rb
检查libxml / parser.h ...否
-----
libxml2缺失。请访问http://nokogiri.org/tutorials/installing_nokogiri.html获取安装依赖关系的帮助。
-----
*** extconf.rb失败***
由于某种原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

提供的配置选项:
--with-opt-dir
--without-opt-dir
...
--with-pkg -config
--without-pkg-config


Gem文件将保留安装在/var/lib/gems/1.8/gems/nokogiri-1.5.6中进行检查。
结果记录到/var/lib/gems/1.8/gems/nokogiri-1.5.6/ext/nokogiri/gem_make.out

我知道厨师资源的通知属性,但仍然可以正常运行。

所以我该如何强迫执行命令首先安装本地软件包,然后在同一次运行中安装gem。



注意:手动安装软件包不是一种选择,因为我们希望这样做为新节点完全自动化。

解决方案

为什么不尝试在资源收集阶段开始时安装依赖项: OPSCODE wiki:从资源集合运行资源



所以你的食谱看起来像:

  xsltdev = packagelibxslt-devdo 
action:nothing
end

xmldev = packagelibxml2-devdo
action:nothing
end

xsltdev.run_action(:install)
xmldev.run_action(:install)

chef_gemfog


I am trying to install the fog gem in a chef recipe though the gem installation occurs before the native packages are being installed so the gem installation fails

package "libxslt-dev"
package "libxml2-dev"

chef_gem "fog"

This is the output

[Thu, 14 Mar 2013 13:04:30 +0000] INFO: Processing chef_gem[fog] action install (ebs4000::update_volumes line 23)
[Thu, 14 Mar 2013 13:04:52 +0000] ERROR: Running exception handlers
[Thu, 14 Mar 2013 13:04:52 +0000] FATAL: Saving node information to /var/cache/chef/failed-run-data.json
[Thu, 14 Mar 2013 13:04:52 +0000] ERROR: Exception handlers complete
[Thu, 14 Mar 2013 13:04:52 +0000] ERROR: Gem::Installer::ExtensionBuildError: chef_gem[fog] (cookbook::recipe line 4) had an error: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.8 extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    ...
    --with-pkg-config
    --without-pkg-config


Gem files will remain installed in /var/lib/gems/1.8/gems/nokogiri-1.5.6 for inspection.
Results logged to /var/lib/gems/1.8/gems/nokogiri-1.5.6/ext/nokogiri/gem_make.out

I am aware of the notifies attribute of the chef resources but still can get this run properly.

So how can I actually force the execution order to first install the native packages and then the gem in the same run.

Note: Manual installation of the packages is not an option, since we want that to be fully automated for new nodes.

解决方案

Why not try installing the dependencies at the start of the resource collection phase, as mentioned here: OPSCODE wiki: Run Resources from the Resource Collection

So your recipe would look like:

xsltdev = package "libxslt-dev" do
   action :nothing
end

xmldev = package "libxml2-dev" do
   action :nothing
end

xsltdev.run_action(:install)
xmldev.run_action(:install)

chef_gem "fog"

这篇关于厨师执行期间在原生扩展包后安装gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆