我和puppet和systemctl有一些麻烦。 我曾经加载了一个“服务”的几个参数,但它不能在centos7上工作。
这是我的错误:
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]:
这是我的代码:
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, } }
它在centos 6上工作得非常好,而且它曾经在centos 7上工作。
如果我像这样定义参数,它是有效的:
ntp::service::ntp_services: "ntpd"
但是我将不得不为1个服务定义1个参数…
谢谢
这条线上的引号可能会导致这个问题:
service {"$ntp_services":
使用""包含一个variables将创build一个string,其中扩展的variables。 这可能是为什么Puppet报告一个单一的服务名称[ntpd ntpdate] (即一个数组)而不是两个不同的服务。
将其更改为:
service { $ntp_services:
这应该通过原始数组,每个项目生成一个资源。