ruby - Chef - Block not being executed even tho its notified?
问题描述
i've looked over this code a few times and i'm not sure why the extract_presta block isnt being triggered. I've confirmed the file i'm looking for isnt in the /var/www/html directory :c)
What i'm trying to achieve is to:
- download a file, unzip it, but only if a specific file doesn't exist
- Stop apache after downloading, unzip the file
- start apache
Could i ask for some advice please? thanks. -nat
service "apache" do
action :nothing
end
execute 'extract_presta' do
command 'unzip /tmp/prestashop_1.7.4.2.zip'
cwd '/var/www/html'
not_if { File.exists?("/var/www/html/autoload.php") }
action :nothing
notifies :start, "service[apache]"
end
# Fetch the file. Maybe the file won't be fetched because of not_if or checksum.
# In that case apache won't be stopped or started, it will just keep running.
remote_file "/tmp/prestashop_1.7.4.2.zip" do
source "https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip"
notifies :stop, "service[apache]", :immediately
notifies :run, 'execute[extract_presta]', :immediately
end
解决方案
下载是否已经存在?如果是这样,那么remote_file
资源将被标记为最新并且不会触发通知。
推荐阅读
- bash - 将 2 行组合在一起但“交错”
- python - 如果值匹配,则将一维数组 (K,1) 转换为具有 1 或 0 的 2D 共识/协议数组 (K,K)
- python - 如果日期范围在开始日期和结束日期之间,则将类别附加到列
- ruby-on-rails - 如何正确处理 Rails 架构源代码控制分支?
- angular - NgRx 8 - 检测到类的不可序列化状态
- qt - 如何在 Windows 上测试不同 DPI/屏幕分辨率的 Qml/Quick UI?
- python - 为什么这个 for 循环不考虑列表?
- javascript - 如何在 js 字符串模板文字中调用带参数的函数?
- java - 未知 HK2 故障多异常
- php - 为 MongoDB 和 MysqlDB X DevApi 创建 PHP 包装器