Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Chef,Apache2 cookbook ressource从自定义资源调用时找不到服务[Apache2]_Apache_Service_Chef Infra_Cookbook_Lwrp - Fatal编程技术网

Chef,Apache2 cookbook ressource从自定义资源调用时找不到服务[Apache2]

Chef,Apache2 cookbook ressource从自定义资源调用时找不到服务[Apache2],apache,service,chef-infra,cookbook,lwrp,Apache,Service,Chef Infra,Cookbook,Lwrp,在我的定制厨师食谱中(位于) 我正在从custom solo.rb配方中调用的自定义资源(LWRP)中调用Apache2 resource web_应用程序 include_recipe 'apache2' web_app url do server_name url server_aliases aliaes cookbook_name 'apache2' docroot dir allow_override 'All' directory_index 'fa

在我的定制厨师食谱中(位于)

我正在从custom solo.rb配方中调用的自定义资源(LWRP)中调用Apache2 resource web_应用程序

    include_recipe 'apache2' 
web_app url do
  server_name url
  server_aliases aliaes
  cookbook_name 'apache2'
  docroot dir
  allow_override 'All'
  directory_index 'false'
  # notifies :reload, 'service[apache2]', :delayed
end
这将返回一个错误:

[#][2016-02-23T23:02:31+00:00]致命:如果您提交错误报告,请提供stacktrace.out文件的内容

[#][2016-02-23T23:02:31+00:00]错误:instanceomeka.dev发生错误:Chef::Exceptions::ResourceNotFound:resource execute[a2enmod headers]配置为通知资源服务[apache2]重新加载操作,但在资源集合中找不到服务[apache2]。execute[a2enmod headers]在/tmp/kitchen/cache/cookbooks/apache2/definitions/apache_module.rb:35:in“block in from_file”中定义

但是,当我直接从自定义配方(第126行)内部调用相同的资源时,它会工作

我的跑步名单如下

   #      - recipe[build-essential]
  - recipe[php::default]
  - recipe[apache2]
  - recipe[apache2::mod_rewrite]
    # - recipe[apache2::mod_expires]
  - recipe[apache2::mod_ssl]
  - recipe[apache2::mod_php5]
  - recipe[omeka::default]
  - recipe[omeka::solo]
attributes:    #      - recipe[build-essential]
  - recipe[php::default]
  - recipe[apache2]
  - recipe[apache2::mod_rewrite]
    # - recipe[apache2::mod_expires]
  - recipe[apache2::mod_ssl]
  - recipe[apache2::mod_php5]
  - recipe[omeka::default]
  - recipe[omeka::solo]
attributes: 
  machine_fqdn: omeka.dev
  machine_fqdn_as_hostname: true
  apache2:
    listen_ports: ["80", "443"]

  machine_fqdn: omeka.dev
  machine_fqdn_as_hostname: true
  apache2:
    listen_ports: ["80", "443"]

这在ubuntu 14.04和centos7上都失败了。

这是一个已知的问题,目前几乎没有解决办法。问题是,使用新的定制资源系统会强制执行
使用内嵌资源
模式,除此之外,这是一个99%的好主意。该模式在自定义资源内创建了一个独立的运行上下文,因此它无法看到其他资源发出的“out”通知。Poise helper库提供了一些工具来解决此问题,但对于Chef core,唯一主要的解决方法是超级不受支持(即,如果没有主要版本,此功能可能会中断):


因此,如果说我正在我的食谱中创建一个资源,我希望能够从其他食谱中使用它,那么我是否应该继续使用旧的LWRP风格,直到上面的内容被整理出来?上面的内容不会被整理出来,这是一个厨师核心团队如何实施事情的系统性问题。与Chef的内部工具相比,Poise的助手或类似项目可能更好地服务于此用例。旧式LWRP也会受到同样的影响,除非您不
使用\u inline\u资源
,您不应该这样做,因为这在排序方面有更奇怪的问题。
web_app url do
  # ...
  notifies :reload, Chef.run_context.resource_collection.find('service[apache2]')
end