文件复制失败使用Puppet文件资源

我正在尝试使用文件资源复制文件。 我的代码如下:

node 'Node-002' { file { "/root/helloworld.txt": ensure => file, owner => "root", group => "root", mode => "0644", source => "puppet://modules/templates/${fqdn}/hosts.erb", } } 

但是由于以下错误而失败

 Error: /Stage[main]/Main/Node[Node-002]/File[/root/helloworld.txt]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/templates/Node-002.example.com/hosts.erb 

模板位置如下所示:

  ls -l /apps/wps/puppetlabs/code/environments/production/modules/templates/Node-002.example.com/hosts.erb -rw-r--r-- 1 puppet puppet 462 Jul 20 02:13 /apps/wps/puppetlabs/code/environments/production/modules/templates/Node-002.wiley.com/hosts.erb 

即使我在source参数中给出了完整的path,也会出现相同的错误。

我正在使用木偶4.5.4

请build议

你的模块看起来不符合标准的目录结构。 使用puppet:///modules/foo/bar.txt的源URL,Puppet将会寻找${codedir}/environments/production/modules/foo/files/bar.txt 。 静态文件应位于模块内的files子目录中。 模板应位于模块内的templates子目录中,并在具有content => template('foo/bar.erb')file资源中引用。 在使用ERB模板作为源代码时,似乎存在一些混淆,不会以任何方式进行处理。

请参阅https://docs.puppet.com/puppet/latest/reference/modules_fundamentals.html了解如何构build模块。