我正在使用Hiera(ruby库,而不是命令行工具或puppet集成)从一组现有的Hiera YAML(我们确实将其用于puppet)中检索数据,以便在Capistrano中使用。我能够按预期工作。。。但我似乎无法摆脱似乎是默认的调试输出:
$ sudo cap deploy
WARN: 2014-10-29 12:17:09 +0000: Not using Hiera::Puppet_logger. It does not report itself to be suitable.
WARN: 2014-10-29 12:17:09 +0000: Cannot load backend puppet: cannot load such file -- hiera/backend/puppet_backend
DEBUG: 2014-10-29 12:17:09 +0000: Hiera YAML backend starting
DEBUG: 2014-10-29 12:17:09 +0000: Looking up package_repo_base in YAML backend
DEBUG: 2014-10-29 12:17:09 +0000: Looking for data source environments/PROD/LDN
DEBUG: 2014-10-29 12:17:09 +0000: Looking for data source regions/LDN
DEBUG: 2014-10-29 12:17:09 +0000: Cannot find datafile /etc/customer/hieradata/regions/LDN.yaml, skipping
DEBUG: 2014-10-29 12:17:09 +0000: Looking for data source environments/PROD
DEBUG: 2014-10-29 12:17:09 +0000: Looking for data source common
DEBUG: 2014-10-29 12:17:09 +0000: Found package_repo_base in common
WARN: 2014-10-29 12:17:09 +0000: Not using Hiera::Puppet_logger. It does not report itself to be suitable.
WARN: 2014-10-29 12:17:09 +0000: Cannot load backend puppet: cannot load such file -- hiera/backend/puppet_backend
DEBUG: 2014-10-29 12:17:09 +0000: Looking up puppet_deploy_base in YAML backend
DEBUG: 2014-10-29 12:17:09 +0000: Looking for data source environments/PROD/LDN
DEBUG: 2014-10-29 12:17:09 +0000: Looking for data source regions/LDN
DEBUG: 2014-10-29 12:17:09 +0000: Cannot find datafile /etc/customer/hieradata/regions/LDN.yaml, skipping
DEBUG: 2014-10-29 12:17:09 +0000: Looking for data source environments/PROD
DEBUG: 2014-10-29 12:17:09 +0000: Looking for data source common
DEBUG: 2014-10-29 12:17:09 +0000: Found puppet_deploy_base in common
**************************************************************************************************************************************************
* Recording output in: deploy.20141029-121709+0000.log *
**************************************************************************************************************************************************
* 2014-10-29 12:17:09 executing `deploy'
* 2014-10-29 12:17:09 executing `deploy:update'
** transaction: start
目前,这只是一个最大的烦恼,但扩展的输出(我已经修剪了上面的输出)使日志记录相当嘈杂,我希望能够消除它。
我通过在deploy.rb:中的hiera调用中设置配置哈希来解决这个问题
def hiera_lookup(key,default=nil,order_override=nil,resolution_type=:priority)
hiera_yaml = File.realpath('./puppet/hiera.yaml')
config = YAML.load_file(hiera_yaml)
config[:logger] = 'noop'
scope = YAML.load_file("/etc/hiera/hiera.conf")
hiera = Hiera.new(:config => config)
hiera.lookup("#{key}", default, scope, order_override, resolution_type)
end
将config[:logger]
键设置为"noop"完全抑制了hiera的输出。