我已经使用hiera几个星期了,直到几天前我才开始收到这样的信息:
错误:无法从远程服务器检索目录:服务器上的错误400 :无法在任何Hiera数据文件中找到数据项nom,并且在节点d0pupeclient.victor-扣.com上没有提供默认的 警告:不在失败的目录上使用缓存 错误:无法检索目录;跳过运行
因此,我尝试做一个非常简单的测试,以检查问题是否来自我上一次的代码更改,而我仍然收到了这条消息。我再也找不到希拉变量了。下面是我所做的测试:
hiera.yaml:
---
:backends:
- yaml
:yaml:
:datadir: /etc/puppet/hieradata
:hierarchy:
- commonsite.pp:
# /etc/puppet/manifests/site.pp
case $operatingsystem {
'Solaris': { include role::solaris }
'RedHat', 'CentOS': { include redhat::roles::common }
/^(Debian|Ubuntu)$/: { include role::debian }
# default: { include role::generic }
}
case $hostname {
/^d0puppetclient/: { include test }
}test.pp:
class test{
$nom = hiera('nom')
file {"/root/test.txt":
ensure => file,
source => "/etc/puppet/test.txt.erb",
}
}test.txt.erb:
<%= nom %>想办法解决这个问题吗?我认为这可能是一个文件访问权问题,所以我尝试授予对某些文件(755)的访问权限,但它不起作用.
发布于 2014-08-09 17:29:27
您需要在您的nom中定义common.yaml,以便它能够保存一个值。如果不打算设置默认值,则可以设置默认值并有条件地创建该文件。
class test {
$nom = hiera('nom', false)
if $nom {
file { '/root/test.txt':
ensure => file,
content => template('test/test.txt.erb')
}
}
}注意我是如何使用content而不是source的。在使用erb模板时,需要使用template()函数指定content。
如果使用source,则需要的是文件而不是erb模板。
希望这能有所帮助。
https://stackoverflow.com/questions/25185772
复制相似问题