与hiera和puppet中的所有虚拟主机共享nginx状态位置

与hiera和puppet中的所有虚拟主机共享nginx状态位置,nginx,puppet,hiera,Nginx,Puppet,Hiera,我正在使用Jfryman puppet nginx模块,并尝试使用可用vHost启用状态位置,因此我的hiera如下所示: --- nginx::nginx_vhosts: 'default': www_root: '/www/default' listen_port: 8081 'default2': www_root: '/www/default2' listen_port: 8082 'default3': www_root: '/w

我正在使用Jfryman puppet nginx模块,并尝试使用可用vHost启用状态位置,因此我的hiera如下所示:

---
nginx::nginx_vhosts:
  'default':
    www_root: '/www/default'
    listen_port: 8081

  'default2':
    www_root: '/www/default2'
    listen_port: 8082

  'default3':
    www_root: '/www/default3'
    listen_port: 8083

nginx::nginx_locations:
  'status':
    location: '/status'
    vhost: 'default'...."here wanna include more than one vhost"
    stub_status: true
在不复制hiera条目的情况下,是否可以说这些VHOST中包含了这样的位置?

否,类型只接受一个参数,并使用它来确定参数

为了保持干燥,您必须避免使用
nginx
类的
nginx\u locations
参数,并自己声明
nginx::resource::location
实例

define status_location_for_vhost() {
    nginx::resource::location { "status-for-$name":
        location => '/status',
        vhost    => $name,
        stub_status => true
    }
}

为每个vhost声明一个状态。

非常感谢您的回答和帮助,但我发现没有必要,因为所有vhost的状态都是通用的,所以为每个主机启用它没有意义