0

这是我用来在我的机器上设置 ntp 以连接到我的源“10.0.2.15”的示例清单

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 配置文件中被替换。

这是我应用 puppet 清单后的 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 变量时;该文件按预期创建。

4

1 回答 1

0

Use double quotes instead of single:

servers => ["${ntpSource} iburst", 'localhost'],

Quote from Puppet site:

There are two kinds of quotes in Puppet: single (') and double ("). The main difference is that double quotes let you interpolate $variables.

于 2013-10-16T20:39:10.170 回答