What is the idiomatic way to install a Debian package using Chef?

≡放荡痞女 提交于 2019-12-03 06:48:00

问题


Below my code for installing vcider. I am learning chef but have not seen anything for installing a dpkg. I would like to use version in the script. The code below works.

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

Even with the code above can I replace 2.0.1b with #{version}? attribute file -> default[:vcider][:version] 2.0.1b

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

回答1:


The Right Thing is to use the built-in resource types. Presuming you've set the version and arch variables appropriately:

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


来源:https://stackoverflow.com/questions/9898614/what-is-the-idiomatic-way-to-install-a-debian-package-using-chef

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!