我有一个安装特定版本的docker的秘诀。我通过属性指定了docker版本。我只是使用该属性。
node.default ['docker'] ['version'] ='1.12.6-1.el7.centos'
配方第一次成功执行,但是当我再次运行它时,它失败了。 当我使用default ['docker'] ['version']以外的任何属性(例如node.default ['docker'] ['xyz'] ='1.12.6-1.el7.centos')时,它在多个收敛上成功执行 谁能知道为什么使用default ['docker'] ['version']
时失败[root@master01 package]# cat _docker.rb
node.default['docker']['version'] = '1.12.6-1.el7.centos'
package "lvm2"
package "device-mapper-persistent-data"
directory "/var/lib/docker"
directory "/etc/docker" do
owner "root"
group "root"
mode "0744"
action :create
recursive true
end
package 'docker-engine' do
version node['docker']['version']
allow_downgrade true
end
service "docker" do
action :enable
end
下面,我使用了属性node.default ['docker'] ['xyz'] ='1.12.6-1.el7.centos',厨师成功运行了该食谱。
[root@master01 package]# cat _docker.rb
node.default['docker']['xyz'] = '1.12.6-1.el7.centos'
package "lvm2"
package "device-mapper-persistent-data"
directory "/var/lib/docker"
directory "/etc/docker" do
owner "root"
group "root"
mode "0744"
action :create
recursive true
end
package 'docker-engine' do
version node['docker']['xyz']
allow_downgrade true
end
service "docker" do
action :enable
end
[root@master01 package]# /opt/chef/bin/chef-apply _docker.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* yum_package[lvm2] action install (up to date)
* yum_package[device-mapper-persistent-data] action install (up to date)
* directory[/var/lib/docker] action create (up to date)
* directory[/etc/docker] action create (up to date)
* yum_package[docker-engine] action install
- install version 1.12.6-1.el7.centos of package docker-engine
使用变量['docker'] ['version']的厨师运行失败,并显示以下错误。
[root@master01 package]# /opt/chef/bin/chef-apply _docker.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* yum_package[lvm2] action install (up to date)
* yum_package[device-mapper-persistent-data] action install (up to date)
* directory[/var/lib/docker] action create (up to date)
* directory[/etc/docker] action create (up to date)
* yum_package[docker-engine] action install
* No candidate version available for docker-engine
================================================================================
Error executing action `install` on resource 'yum_package[docker-engine]'
================================================================================
Chef::Exceptions::Package
-------------------------
No candidate version available for docker-engine
Resource Declaration:
---------------------
# In _docker.rb
16: package 'docker-engine' do
17: version node['docker']['version']
18: # version node['docker']['version']
19: allow_downgrade true
20: end
21:
Compiled Resource:
------------------
# Declared in _docker.rb:16:in `run_chef_recipe'
yum_package("docker-engine") do
package_name "docker-engine"
action [:install]
default_guard_interpreter :default
declared_type :package
cookbook_name "(chef-apply cookbook)"
recipe_name "(chef-apply recipe)"
version "17.03.2"
allow_downgrade true
end
System Info:
------------
chef_version=14.2.0
platform=centos
platform_version=7.4.1708
ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
program_name=/opt/chef/bin/chef-apply
executable=/opt/chef/bin/chef-apply
[2018-07-05T07:40:49+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2018-07-05T07:40:49+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-07-05T07:40:49+00:00] FATAL: Chef::Exceptions::Package: yum_package[docker-engine] ((chef-apply cookbook)::(chef-apply recipe) line 16) had an error: Chef::Exceptions::Package: No candidate version available for docker-engine
指定的版本在我们的自定义存储库中可用,并且我可以使用yum手动安装该版本。那么谁能知道为什么它会显示这种行为?
厨师版
chef_version=14.2.0
ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
program_name=/opt/chef/bin/chef-apply
executable=/opt/chef/bin/chef-apply