我想通过木偶添加连续的crons,第一个设置为每10分钟,第二个设置为星期日晚上7点。
puppet中的第一个cron工作正常,但第二个cron显示以下错误:“错误:无法从远程服务器检索目录:SERVER上的错误400:无效关系:Cron [notifyinactivetargetweekly] {require => File [... weeklynotifyinactivejob.sh]},因为File [... weeklynotifyinactivejob.sh]似乎不在目录中警告:未在失败的目录上使用缓存错误:无法检索目录;跳过运行“
以下是清单代码。
cron { 'firstcron':
command => "${scmphptpl::DocRootDir}/firstcron.sh ${scmphptpl::Environment} ${scmphptpl::DocRootDir}",
require => File["${scmdemophp::DocRootDir}/firstcron.sh"],
minute => '*/10',
environment=>["COMPOSER_HOME=${scmphptpl::DocRootDir}",
"SYMFONY_ENV=${scmphptpl::Environment}",
"SYMFONY_DEBUG=${scmphptpl::Debug}",
"PATH=/opt/rh/php55/root/usr/bin:/opt/rh/php55/root/usr/sbin:/usr/local/sbin:/usr/local/bin:/sbin/:/bin/:/usr/sbin/:/usr/bin/"
],
}->
cron { 'weeklynotifyinactivejob':
command => "${scmphptpl::DocRootDir}/weeklynotifyinactivejob.sh ${scmphptpl::Environment} ${scmphptpl::DocRootDir}",
require => File["${scmphptpl::DocRootDir}/weeklynotifyinactivejob.sh"],
minute => '00',
hour => '19',
weekday => 'Sunday',
environment=>["COMPOSER_HOME=${scmphptpl::DocRootDir}",
"SYMFONY_ENV=${scmphptpl::Environment}",
"SYMFONY_DEBUG=${scmphptpl::Debug}",
"PATH=/opt/rh/php55/root/usr/bin:/opt/rh/php55/root/usr/sbin:/usr/local/sbin:/usr/local/bin:/sbin/:/bin/:/usr/sbin/:/usr/bin/"
],
}->
hieradata包含以下类加载:
classes:
- scmphptpl::myprojectdeploy
myprojectdeploy的init.pp包含:
class scmphptpl {
$DocRootDir = "/app/code"
我检查了文件“/app/code/weeklynotifyinactivejob.sh”是否存在。
更新:
我创建了相同的,但由于某种原因,cron没有按时间运行:
file { "${DocRootDir}/weeklynotifyinactivejob.sh":
ensure => file,
content => "... whatever's in the file, or use a template/source ...",
}->
cron { 'notifyinactivetargetweekly':
command => "${scmphptpl::DocRootDir}/weeklynotifyinactivejob.sh ${scmphptpl::Environment} ${scmphptpl::DocRootDir}",
require => File["${scmdemophp::DocRootDir}/weeklynotifyinactivejob.sh"],
minute => '*/15',
environment=>["COMPOSER_HOME=${scmphptpl::DocRootDir}",
"SYMFONY_ENV=${scmphptpl::Environment}",
"SYMFONY_DEBUG=${scmphptpl::Debug}",
"PATH=/opt/rh/php55/root/usr/bin:/opt/rh/php55/root/usr/sbin:/usr/local/sbin:/usr/local/bin:/sbin/:/bin/:/usr/sbin/:/usr/bin/"
],
}
但它在15分钟后没有运行,需要帮助
使用require
,before
,subscribe
或notify
参数表示资源与文件或其他资源相关必须包含有效引用。
您正在使用的require
参数需要在Puppet清单中定义的特定文件资源,而不一定是服务器本身上的文件。这就是文件不在目录中的含义(目录是从清单构建的)。
require => File["${scmdemophp::DocRootDir}/notifyinactivetargetweekly.sh"],
这意味着您的清单中必须有一个名为/app/code/notifyinactivetargetweekly.sh
的文件资源,例如在scmdemophp类中你可以拥有:
file { "${DocRootDir}/notifyinactivetargetweekly.sh":
ensure => file,
content => "... whatever's in the file, or use a template/source ...",
}
然后可以解决require
依赖关系。
如果您不希望使用Puppet管理文件,则只需将require
参数保留。