让模块与对方交谈

我目前正在通过确保服务和用户被禁用来处理configuration文件来locking服务器。 例如,Apache。

当另一个configuration文件想要pipe理资源时,这会产生问题,因为那样我将拥有两个Service [apache]资源。

现在我可以使用类似于define的东西了,但是我的首选方法是profile :: apache可以和profile :: lockdown交谈,并告诉它离开apache。

我想,你需要使用hiera来存档你想要的。

class profiles::apache { class { '::apache': } } 

现在如果我的类profiles::apache开始用于1000个节点,我想停止服务在一个特定的服务器,在hiera我可以使用这样的事情。

hiera 3configuration示例hiera.yaml

 --- :backends: - yaml - json :yaml: :datadir: "/etc/puppetlabs/code/environments/%{::environment}/hieradata" :json: :datadir: "/etc/puppetlabs/code/environments/%{::environment}/hieradata" :hierarchy: - "nodes/%{::trusted.certname}" - "virtual/%{::virtual}" - "common" 

现在在/etc/puppetlabs/code/environments/production/hieradata/nodes/servername.domain.local.yaml插入这个apache::service_ensure: stopped

用hiera你可以通过节点或别的东西来操作类的参数