我尝试在服务器上安装本地烘焙的包:
cookbook_file '/var/cache/apt/archives/nfdhcpd_0.20_all.deb' do
source 'nfdhcpd_0.20_all.deb'
owner 'root'
group 'root'
mode '0755'
action :create
end
package 'nfdhcpd_0.20_all.deb' do
provider Chef::Provider::Package::Dpkg
source "/var/cache/apt/archives/nfdhcpd_0.20_all.deb"
action :install
end
我需要使用,dpkg provider
因为apt provider
不支持本地包(apt package provider cannot handle source attribute. Use dpkg provider instead
)。我收到错误(缺少 deps):
STDERR: dpkg: dependency problems prevent configuration of nfdhcpd:
nfdhcpd depends on python-scapy (>= 2.0.1-1); however:
Package python-scapy is not installed.
我怎样才能告诉 Chef 安装缺少的依赖项?(无需手动安装)
答案1
dpkg
无法安装依赖项,因此您需要创建一个包含您的包的本地 apt 存储库。https://askubuntu.com/a/176546给出了基本思想。您需要将Packages
文件与您的放在一起.deb
,然后在文件中引用该目录/etc/apt/sources.list.d
。
file '/etc/apt/sources.list.d/local-apt.list' do
owner 'root'
group 'root'
mode '0644'
content "deb file:/var/cache/apt/archives/ ./"
action :create
notifies :run, 'execute[apt-get update]', :immediately
end
package 'nfdhcpd'
答案2
那么将其-f
作为选项传递怎么样?
package 'debian-archive-keyring' do action :install options '--force-yes' end
apt_package 'name' do default_release String notifies # see description options String package_name String, Array # defaults to 'name' if not specified provider Chef::Provider::Package::Apt source String subscribes # see description timeout String, Integer version String, Array action Symbol # defaults to :install if not specified end
dpkg_package 'name' do notifies # see description options String package_name String, Array # defaults to 'name' if not specified provider Chef::Provider::Package::Dpkg source String subscribes # see description timeout String, Integer version String, Array action Symbol # defaults to :install if not specified end
选项
Ruby 类型:字符串
传递给命令的一个(或多个)附加选项。