厨师:为什么我不能订阅目录:创建动作?

时间:2013-09-18 13:30:07

标签: chef vagrant provisioning chef-recipe chef-solo

我创建了以下配方块,它应该在创建/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

(这是直接建模opscode example - 在“存储数据包中的文件”下)

在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)

但它没有运行我的代码。

我做错了什么?

2 个答案:

答案 0 :(得分:0)

将操作:nothing更改为:run ..

答案 1 :(得分:-1)

您是否尝试过subscribes :create, "directory[/etc/httpd/ssl]"