背景
我想申请这个想法有一个common类,其中包括所有关于我的设置的具体信息。
所以我创build了/etc/puppet/modules/common/manifests/init.pp
class common { include common::data } class common::data { $ntpServerList = [ 'ntp51.ex.com','ntp3.ex.com' ] }
并安装了这个 ntp模块,并创build了一个像这样的节点
node testip { include myconfig::ntpp }
问题
/etc/puppet/modules/myconfig/manifests/init.pp包含
class myconfig::ntpp { include common class {'ntp': server_list => $ntpServerList # server_list => ['ntp.ex.com'] # this works } }
而且我会期望$ntpServerList将可用,但事实并非如此。 错误是
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template ntp/ntp.conf.erb: Filepath: /usr/lib/ruby/site_ruby/1.8/puppet/parser/templatewrapper.rb Line: 64 Detail: Could not find value for 'server_list' at /etc/puppet/modules/ntp/templates/ntp.conf.erb:25 at /etc/puppet/modules/ntp/manifests/init.pp:183 on node testip
题
任何人都可以找出我的myconfig::ntpp类有什么问题吗?
你需要完全限定你的variables。 $common::data::ntpServerList 。
就这样,你的代码在本地范围( $myconfig::ntpp::ntpServerList )中寻找一个名为ntpServerList的variables( $myconfig::ntpp::ntpServerList ),这个variables不存在,所以它回退到顶端作用域( $::ntpServerList )不存在。
在这里看到更多的细节。