【问题标题】:What is the idiomatic way to install a Debian package using Chef?使用 Chef 安装 Debian 软件包的惯用方法是什么?
【发布时间】:2012-04-11 12:28:59
【问题描述】:

下面是我安装 vcider 的代码。我正在学习厨师,但没有看到任何安装 dpkg 的东西。我想在脚本中使用版本。下面的代码有效。

script "install_vcider" do
  interpreter "bash"
  user "root"
  cwd "/tmp"
  code <<-EOH
  wget https://my.vcider.com/m/downloads/vcider_2.0.1b_amd64.deb
  dpkg -i vcider__amd64.deb
  EOH
end

即使使用上面的代码,我也可以将 2.0.1b 替换为 #{version} 吗? 属性文件 -> 默认[:vcider][:version] 2.0.1b

recipe file - > version = node[:vcider][:version]

【问题讨论】:

    标签: chef-infra


    【解决方案1】:

    正确的做法是使用内置资源类型。假设您已正确设置 versionarch 变量:

    remote_file "/tmp/vcider_#{version}_#{arch}.deb" do
      source "https://my.vcider.com/m/downloads/vcider_#{version}_#{arch}.deb"
      mode 0644
      checksum "" # PUT THE SHA256 CHECKSUM HERE
    end
    
    dpkg_package "vcider" do
      source "/tmp/vcider_#{version}_#{arch}.deb"
      action :install
    end
    

    【讨论】:

    • 谢谢:) 另外....安装后是否正确?服务“vcider-nmd”确实支持:status => true,:restart => true,:reload => true action [:enable,:start] end
    • @Tampa 看起来很合理。不过,我实际上很不幸现在在一家木偶店,所以我的厨师越来越生疏了。
    • @Tampa 哎呀——我开始在那里添加其他内容,但在发表评论之前分心/未能完成。
    猜你喜欢
    • 2017-12-30
    • 1970-01-01
    • 1970-01-01
    • 2013-06-30
    • 2012-02-15
    • 2011-05-23
    • 2018-05-21
    • 2019-01-14
    • 1970-01-01
    相关资源
    最近更新 更多