我知道我们可以在运行cookbook时包含版本
chef-client -o "recipe[mycookbook@0.1.1]"
Run Code Online (Sandbox Code Playgroud)
在执行include_recipe时如何添加版本
include_recipe "apache2::mod_ssl"@version?
Run Code Online (Sandbox Code Playgroud)
这include_recipe在Chef Recipe DSL中无法使用.您提供特定版本的选项正在使用:
"recipe[mycookbook@0.1.1]"固定食谱的环境,例如:
cookbook_versions({"nginx"=>"<= 1.1.0","apt"=>"= 0.0.1"})
depends 'apt', '1.2.3'.既然你想要在一本食谱中加一个版本,为什么不把它宣布呢metadata.rb?这将对include_recipe您正在使用的语句产生直接影响,强制包括使用元数据中声明的版本.
在您的示例中,那将是:
depends 'mycookbook, '0.1.1'
Run Code Online (Sandbox Code Playgroud)
或者在您的metadata.rb文件中使用apache示例:
depends 'apache2', 'version'
Run Code Online (Sandbox Code Playgroud)
然后在你的食谱中:
include_recipe "apache2::mod_ssl"
Run Code Online (Sandbox Code Playgroud)