Chef infra 厨师执行此食谱的命令
我有以下厨师食谱Chef infra 厨师执行此食谱的命令,chef-infra,chef-recipe,chef-solo,Chef Infra,Chef Recipe,Chef Solo,我有以下厨师食谱 lazy_message = 'Hello world' file 'lazy_message' do path '/tmp/lazy.txt' content "#{lazy_message}" end execute 'yum-makecache' do command 'yum makecache' notifies :create, 'file[message]', :immediately action :nothing end packag
lazy_message = 'Hello world'
file 'lazy_message' do
path '/tmp/lazy.txt'
content "#{lazy_message}"
end
execute 'yum-makecache' do
command 'yum makecache'
notifies :create, 'file[message]', :immediately
action :nothing
end
package 'bind-utils' do
action :install
notifies :run, 'execute[yum-makecache]', :before
end
file 'message' do
path '/tmp/message.txt'
content lazy { "#{lazy_message}" }
end
lazy_message = 'Goodbye world'
当我运行它时,它将按以下顺序执行
Synchronizing Cookbooks:
- lcd_web (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 4 resources
Recipe: lcd_web::default
* file[lazy_message] action create
- create new file /tmp/lazy.txt
- update content in file /tmp/lazy.txt from none to 64ec88
--- /tmp/lazy.txt 2018-07-28 07:47:39.433257401 +0000
+++ /tmp/.chef-lazy20180728-296-7usgw7.txt 2018-07-28 07:47:39.433257401 +0000
@@ -1 +1,2 @@
+Hello world
* execute[yum-makecache] action nothing (skipped due to action :nothing)
* yum_package[bind-utils] action install
- install version 32:9.9.4-61.el7.x86_64 of package bind-utils
* file[message] action create
- create new file /tmp/message.txt
- update content in file /tmp/message.txt from none to b4dabd
--- /tmp/message.txt 2018-07-28 07:47:52.115780144 +0000
+++ /tmp/.chef-message20180728-296-tgnjuk.txt 2018-07-28 07:47:52.115780144 +0000
@@ -1 +1,2 @@
+Goodbye world
* execute[yum-makecache] action run
- execute yum makecache
* file[message] action create (up to date)
我不理解使用lazy block、:before和:立即指令的执行顺序
根据我的意见,执行命令如下
- 执行文件“惰性消息”
- 转到yum'makecache',但由于无操作而跳过它
- 转到绑定utils,但由于:before指令再次跳转执行“yum-makecache”,并运行它
- 由于“yum-makecache”中的immediatelyn运行文件“message”
- 现在运行绑定utils
- 再次运行文件“消息”
但实际输出并不像“yum-makecache”之前运行的“bind-utils”
通知非常挑剔,基本上只用于在无法升级正在运行的服务的平台上进行包/文件更新之前停止服务。在计时之前再挂一次通知肯定会做一些不合逻辑的事情,我们不测试也不关心它的行为,因为我从来没有听说过这样做的真正原因。记住,Chef已经对订单敏感了,你不能使用:在
强制执行订单之前,它只适用于那种升级情况