大网数据广告活动
服务器运维问答

File Copy failing using Puppet File resource

· 52CE 我爱测

I am trying to copy files using file resource . My code is as follows: node 'Node-002' { file { "/root/helloworld.txt": ensure => file, owner => "root", group => "root", mode => "0644", source => "puppet://modules/templates/${fqd…

问题原文

原帖链接 · Zama Ques · CC BY-SA 3.0

I am trying to copy files using file resource . My code is as follows:

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

But it is failing with the following error

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

The template location is as follows:

  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

Even if I give the full path in the source parameter , it is failing with the same error.

I am using Puppet 4.5.4

Please suggest

已采纳解答

原帖链接 · bodgit · CC BY-SA 3.0

Your module(s) don't appear to conform to the standard directory structure. With a source URL of puppet:///modules/foo/bar.txt, Puppet will be looking for ${codedir}/environments/production/modules/foo/files/bar.txt. Static files should be in a files subdirectory within your module. Templates should be in a templates subdirectory within your module and referenced in a file resource with content => template('foo/bar.erb'). There seems to be some confusion with you using an ERB template as a source which won't get processed in any way.

See https://docs.puppet.com/puppet/latest/reference/modules_fundamentals.html for how your modules should be structured.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。