Puppet:如何使用 service with schedule

Puppet : How to use service with schedule

我想安排在某个时间段(时间表)重新启动服务。
我尝试了多种变体,但 none 都成功了。希望有人知道我做错了什么:

schedule { 'my_sched':
  range   => '11:00 - 11:20',
  period => daily,
  repeat => 1,
}

service { 'my_service':
  ensure    => 'running',
  enable    => true,
  schedule  => 'my_sched',
}

如果我用 exec 替换服务,它工作正常。
如果我用文件依赖项替换时间表,它也能正常工作。
但服务不适用于 schedule

文档here中解释说:

Currently, schedules can only be used to stop a resource from being applied; they cannot cause a resource to be applied when it otherwise wouldn’t be, and they cannot accurately specify a time when a resource should run.

这就是问题所在;该服务已经在您的日程安排中 运行,因此 Puppet 会看到它是 运行 并发现没有什么可做的。

也许只使用 cron?我会让 Puppet 安装一个 cron 作业来重新启动服务。