大网数据广告活动
服务器运维问答

Puppet and systemctl trouble

· 52CE 我爱测

I have some trouble with puppet and systemctl. I used to load several parameters for a 'service' but it's not working anymore on centos7. This is my error: Error: Could not enable [ntpd ntpdate]: Error: /Stage[main]/Ntp::Service/…

问题原文

原帖链接 · Skullone · CC BY-SA 3.0

I have some trouble with puppet and systemctl. I used to load several parameters for a 'service' but it's not working anymore on centos7.

This is my error:

Error: Could not enable [ntpd ntpdate]: 
Error: /Stage[main]/Ntp::Service/Service[[ntpd ntpdate]]/enable: change from false to true failed: Could not enable [ntpd ntpdate]: 

And this is my code :

Hiera :

ntp::service::ntp_services: 
  - "ntpd"
  - "ntpdate"

Service.pp :

class ntp::service ($ntp_services) {
    service {"$ntp_services":
        hasrestart  => false,
        hasstatus   => true,
        ensure      => running,
        enable      => true,
    }
}

It's working very well on centos 6 and it used to work on centos 7.

It works if I define the parameter like that :

ntp::service::ntp_services: "ntpd"

But I will have to define 1 parameter for 1 service...

Thanks

已采纳解答

原帖链接 · Dominic Cleal · CC BY-SA 3.0

The quotes on this line are likely to be causing the problem:

service {"$ntp_services":

Using "" containing a variable will create a string with the variable expanded inside it. This is probably why Puppet is reporting a single service with the name [ntpd ntpdate] (i.e. an array) rather than two different services.

Change it to:

service { $ntp_services:

and this should pass the original array, generating one resource per item.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。