我创建了以下配方块,它应该在/etc/httpd/ssl
创建目录时运行:
ruby_block "Copy SSL certificates" do
block do
certificate_file = "#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_filename']}"
key_file = "#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_key_filename']}"
chain_file = "#{node['magento']['apache']['project_ssl_location']}/#{node['magento']['apache']['ssl_certificate_chain_filename']}"
if File.exists?(certificate_file) && File.exists?(key_file)
FileUtils.cp(certificate_file, "#{node['apache']['dir']}/ssl")
FileUtils.cp(key_file, "#{node['apache']['dir']}/ssl")
end
if File.exists?(chain_file)
FileUtils.cp(chain_file, "#{node['apache']['dir']}/ssl")
end
end
action :nothing
subscribes :create, resources(:directory => "/etc/httpd/ssl")
end
(这直接模仿了操作码示例- 在“将文件存储在数据包中”下)
在 Chef 输出中,我可以看到我的食谱文件正在加载:
[2013-09-18T13:19:45+00:00] DEBUG: Loading Recipe chef-magento::copy_ssl_certificates via include_recipe
而且,在下面,我可以看到正在创建的目录:
[2013-09-18T13:22:40+00:00] INFO: Processing directory[/etc/httpd/ssl] action create (apache2::default line 138)
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] created directory /etc/httpd/ssl
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] owner changed to 0
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] group changed to 0
[2013-09-18T13:22:40+00:00] INFO: directory[/etc/httpd/ssl] mode changed to 755
[2013-09-18T13:22:40+00:00] INFO: Processing directory[/etc/httpd/conf.d] action create (apache2::default line 145)
但它绝不会运行我的代码。
我究竟做错了什么?