如何解决Puppet完全限定的参数path错误?

当我在机器上运行puppet客户端(非守护进程)时,我经常但随机地得到以下错误消息:

错误:无法创build:参数path失败:文件path必须完全限定
警告:在失败的目录上不使用caching
警告:configuration无法实例化:参数path失败:文件path必须是完全限定的

这似乎是适度清楚的意思 – 我没有一个完全合格的参数path。 但是,它不告诉我在哪里可以find这个修复它,甚至哪个参数是错误的:(

(如果我使用debugging选项,它会一直工作,所以它似乎是一个清单caching的问题…这将是很好的摆脱这个生产使用,仍然)

注意:我不能一直这样做 :/

[回答自己的问题后,在刺激一段时间刺激]

我已经设法跟踪到我写的模块之一(当然),但是这是由于使用了一个variables,没有达到我的预期。

发生了什么事是:

$variable_dir = "/etc/puppet/bar" class foo { file { $variable_dir: ensure => directory } } define some-define() { # Trimmed for brevity exec { "some-$name": # command, creates, timeout etc here require => File[$variable_dir], } } 

这基本上导致了一些与File []使用variables混淆。 我已经用这个variables的显式值代替了它们,这一切都很好,但这真是一个惊喜! 我假设我对范围的理解以及何时可以定义/使用variables与Puppet有些不同,所以我将会学习到更好的…

它似乎导致了相同的行为,因为使用未完全限定的文件stringpath,未能findvariables或没有获得值? 不pipe怎样,这很奇怪。

编辑:这是很有可能的variables没有被发现在范围内,所以是空的,绝对不是一个完全合格的path。 不能解释为什么这是不一致的,但是…

当你testing你的木偶configuration时,你可以通过运行来完成

 puppetd --test 

这将给你更详细的输出,它应该告诉你失败的地方。 如果你真的很绝望,你可以--debug以获得更多的输出。

如果你想看你的.pp文件,你应该search一个

 file { "path/to/file": ... } 

其中有一个遗漏/ (即它应该读/path/to/file而不是)

你可以把path属性的实际path,然后它的作品。 这适用于我:

 $variable_dir = "/etc/puppet/bar" class foo { file { 'variable_dir': path => ${variable_dir}, ensure => directory } } define some-define() { # Trimmed for brevity exec { "some-$name": # command, creates, timeout etc here require => File['variable_dir'], } } 

除非您使用path参数,否则完整path应放置在密钥名称中。

例如:

 file { '/full/path': ensure => directory, recurse => true, } 

要么:

 file { 'my name': path => "/full/path", ensure => directory, recurse => true, } 

如果你正在使用variables,确保它已被定义。 如果它在不同的类中,使用标准的$class::variable语法。 有关更多信息,请使用-vd (verbose + debug)参数运行puppet。