首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用傀儡的ntp内置类安装ntp

使用傀儡的ntp内置类安装ntp
EN

Stack Overflow用户
提问于 2013-10-16 16:29:37
回答 1查看 1.2K关注 0票数 0

下面是我的示例清单,用于在计算机上设置ntp,以连接到源“10.0.2.15”

代码语言:javascript
复制
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文件,

代码语言:javascript
复制
# 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变量时,该文件将按预期的方式创建。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-16 20:39:10

用双引号代替单引号:

服务器=> "${ntpSource} iburst",“localhost”,

来自木偶网站的报价:

木偶中有两种引号:单引号(')和双引号(")。主要区别是双引号允许您插入$variables。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19408778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档