0

ソース '10.0.2.15' に接続するためにマシンに 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 構成に挿入しています。

このマニフェストを実行すると、ntp.conf 構成ファイルで $ntpSource 変数が置き換えられません。

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 に答える