这是我的/etc/puppet/puppet.conf一个片段
[main] modulepath = /etc/puppet
当我尝试在init.pp文件中使用此path时,出现错误
etc/puppet/modules/fangs/manifests# puppet apply init.pp err: /Stage[main]//File[/tmp/test]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/fangs/files/sample.txt at /etc/puppet/modules/fangs/manifests/init.pp:7 notice: Finished catalog run in 0.05 seconds
这是我的init.pp文件的内容
file { '/tmp/test': ensure => file, mode => '0777', source => "puppet:///modules/fangs/files/sample.txt", # source => "/etc/puppet/modules/fangs/files/sample.txt", }
当我使用注释源source => "/etc/puppet/modules/fangs/files/sample.txt",以完整的文件path而不是puppet:// modulepath运行。
我怎样才能修复我的模块path,以确保这个工作正常?
除非你想自定义modules文件夹的布局,否则不需要在modulepath中设置modulepath /etc/puppet.conf 。 /etc/puppet/modules:/usr/share/puppet/modules (在开放源代码版本中)或/etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules (在木偶企业)。 如果这不是你的情况,请设置:
modulepath=/etc/puppet/modules
Shane Madden的信息是正确的,但是它不适用于你当前的modulepath设置,因为puppet会直接在/etc/puppet下查找你的模块。 除非你想把它们放在那里(你可能不这样做),你需要修复modulepath并使用:
source => "puppet:///modules/fangs/sample.txt",
正如Shane所build议的。
当使用puppet://path时,暗含“文件”。
相反,请尝试:
source => "puppet:///modules/fangs/sample.txt",