2013-10-16 64 views
0

這裏是我用來設置NTP我的機器上連接到我的源'10我的示例清單.0.2.15'設置NTP使用木偶的NTP內置類

class myNtpClass ($ntpSource='10.0.2.15') { 

file {'myFile': 
     ensure => present, 
     path => '/test2', 
     content => "servers => ['${ntpSource} iburst']", 
} 

class { '::ntp': 

servers => ['${ntpSource} iburst', 'localhost'], 
restrict => ['restrict 127.0.0.1', 'restrict 10.0.2.0/24'], 
} 

} 

include myNtpClass 

我使用的是內置的NTP類來將我的源服務器列表插入到我的ntp配置中。

當我執行這個清單時,$ ntpSource變量不會在我的ntp.conf配置文件中被替換。

這裏是運用木偶清單後,我的ntp.conf文件,

# ntp.conf: Managed by puppet. 
# 
# Keep ntpd from panicking in the event of a large clock skew 
# when a VM guest is suspended and resumed. 
tinker panic 0 

# Permit time synchronization with our time source, but do not' 
# permit the source to query or modify the service on this system.' 
restrict 127.0.0.1 
restrict 10.0.2.0/24 


# Servers 
server ${ntpSource} iburst 
server localhost 


# Driftfile. 
driftfile /var/lib/ntp/drift 

我不知道我要去的地方錯了。 當我嘗試在文件中打印$ ntpSource變量時;該文件按預期創建。

回答

0

用雙引號代替單:

服務器=> [ 「$ {ntpSource}的iBurst」, '本地主機'],

從木偶站點引用:

Puppet中有兩種引用:single(')和double(「)。 主要區別在於雙引號可以插入 $變量。

+0

非常感謝 – user2887201