Issue
I want to add successive crons via puppet, first one to set as each 10 minutes, and the 2nd one to run in Sunday 7:00PM.
The first cron in puppet is working properly, but the 2nd one shows the below error: "Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid relationship: Cron[notifyinactivetargetweekly] { require => File[...weeklynotifyinactivejob.sh] }, because File[...weeklynotifyinactivejob.sh] doesn't seem to be in the catalog Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run"
Below are the manifest code.
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/"
],
}->
The hieradata consists the below classloading:
classes:
- scmphptpl::myprojectdeploy
the init.pp of myprojectdeploy consists:
class scmphptpl {
$DocRootDir = "/app/code"
and I checked that the file "/app/code/weeklynotifyinactivejob.sh" exists.
UPDATES:
I have created the same, but for some reason the cron is not running as per timing:
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/"
],
}
but its not running after 15 minutes, need help
- The puppet log says: File[/app/code/edlconsole/firstcron.sh]/mode: mode changed '0664' to '0751'
- but it does not showing the same for File[/app/code/edlconsole/weeklynotifyinactivejob.sh]/mode: mode changed '0664' to '0751'
- frequency changes are reflecting though
Solution
Using a require
, before
, subscribe
or notify
parameter to say that a resource is related to a file or other resource must contain a valid reference.
The require
parameter you're using is requiring a particular file resource defined in your Puppet manifests, not necessarily a file on the server itself. This is what it means by the file not being in the catalog (the catalog is built from manifests).
require => File["${scmdemophp::DocRootDir}/notifyinactivetargetweekly.sh"],
This means that there must be a File resource called /app/code/notifyinactivetargetweekly.sh
defined in your manifest, e.g. in the scmdemophp class you could have:
file { "${DocRootDir}/notifyinactivetargetweekly.sh":
ensure => file,
content => "... whatever's in the file, or use a template/source ...",
}
And then the require
dependency can be resolved.
If you don't wish to manage the file with Puppet, then simply leave the require
parameter out.
Answered By - Dominic Cleal Answer Checked By - Clifford M. (WPSolving Volunteer)