Skip to main content

How to add successive cron via puppet

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[...notifyinactivetargetweekly.sh] }, because File[...notifyinactivetargetweekly.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 { 'firstsynccron':
    command => "${phpapp::DocRootDir}/firstcronsync.sh ${scmdemophp::Environment} ${phpapp::DocRootDir}",
    require => File["${phpapp::DocRootDir}/firstcronsync.sh"],
    minute  => '*/10',
    environment=>["COMPOSER_HOME=${phpapp::DocRootDir}",
                    "SYMFONY_ENV=${phpapp::Environment}",
                    "SYMFONY_DEBUG=${phpapp::Debug}",
                    "PATH=.../usr/local/sbin:/usr/local/bin:/sbin/:/bin/:/usr/sbin/:/usr/bin/"
                ],

}->
cron { 'notifyweeklycron':
    command => "${phpapp::DocRootDir}/notifyweeklycron.sh ${phpapp::Environment} ${phpapp::DocRootDir}",
    require => File["${phpapp::DocRootDir}/notifyweeklycron.sh"],
    minute  => '00',
    hour  => '19',
    weekday  => 'Sunday',
    environment=>["COMPOSER_HOME=${phpapp::DocRootDir}",
                    "SYMFONY_ENV=${phpapp::Environment}",
                    "SYMFONY_DEBUG=${phpapp::Debug}",
                    "PATH=.../usr/local/sbin:/usr/local/bin:/sbin/:/bin/:/usr/sbin/:/usr/bin/"
                ],

}->
The hieradata consists the below classloading:
classes:
  - phpapp::mysymfonydeploy
the init.pp of edsconsoledeploy consists:
class scmdemophp {
    $DocRootDir = "/var/code"
and I checked that the file "/app/code/notifyinactivetargetweekly.sh" exists.

UPDATES:

I have created the same, but for some reason the cron is not running as per timing:
file { "${DocRootDir}/notifyweeklycron.sh":
  ensure  => file,
  content => "... whatever's in the file, or use a template/source ...",
}->
cron { 'notifyweeklycron':
    command => "${phpapp::DocRootDir}/notifyweeklycron.sh ${phpapp::Environment} ${phpapp::DocRootDir}",
    require => File["${phpapp::DocRootDir}/notifyweeklycron.sh"],
    minute  => '*/15',
    environment=>["COMPOSER_HOME=${phpapp::DocRootDir}",
                    "SYMFONY_ENV=${phpapp::Environment}",
                    "SYMFONY_DEBUG=${phpapp::Debug}",
                    "PATH=.../usr/local/bin:/sbin/:/bin/:/usr/sbin/:/usr/bin/"
                ],

}
but its not running after 15 minutes, need help
  1. The puppet log says: File[/var/code/firstsynccron.sh]/mode: mode changed '0664' to '0751'
  2. but it does not showing the same for File[/var/code/notifyweeklycron.sh]/mode: mode changed '0664' to '0751'
  3. frequency changes are reflecting though
I was so confused and searching what to do, I received an answer on a tech forum, and that I want to describe here:



What I was missing was using a requirebeforesubscribe or notify parameter, which says that a resource is related to a file or other resource must contain a valid reference.

The require is requiring a file resource which is defined in your Puppet manifests, and also surprisingly it does not necessarily a file on the server location. So what was there in my code:
require => File["${phpapp::DocRootDir}/notifyinactivetargetweekly.sh"],
So puppet was expecting, a file resource destined at /var/code/notifyweeklycron.shshould exist as per my manifest, and the fix was:
file { "${phpapp:DocRootDir}/notifyweeklycron.sh":
  ensure  => file,
  content => "... whatever's in the file, or use a template/source ...",
}
My require issue has been resolved.

Comments

Popular posts from this blog

SimpleSAML Installation in Windows Apache

Say you want to install SimpleSAMLphp in windows Apache/Xampp. Let me tell you what I did so far: I have downloaded latest stable version from  https://simplesamlphp.org/download  and placed the unzipped file in Apache folder, i.e. C:\Apache24\simplesamlphp directory contains composer.json. I have downloaded dependencies as well. Now when I am going to setup the vhost as shows in the site 6. Configuring Apache section as <VirtualHost *:80 > ServerName localhost DocumentRoot C:/Apache24/htdocs <VirtualHost *:80 > ServerName service.example.com DocumentRoot C:/Apache24/service.example.com Alias /simplesaml C:/Apache24/simplesamlphp/www Changed the config file Now I faced the problem: I am unable to open the Alias in browser. And running httpd.exe in browser shows error about the example.com does not exist. Later I found that I was doing some mistake... I am going to add one vhost, rather ...

Once before lockdown

It was the end of March 2020, and I was a little scared. I had a production movement planned, and for team integration, I must be present in the office. It’s a story of that day, which is nearly 1.5 months earlier, the Covid-19 lockdown already declared. And some of my colleagues decided to reach very early in the morning, finish everything, and then come back home. I was at the bus stop; few buses were coming and all of those will not go till the end destination. I unknowingly, almost step inside a bus, and the conductor ceased me, asking where I wanted to go. I got a kick and he told me that he’ll not go till SEZ area, and he warned me about the lockdown condition. With a half an hour waiting, thanks to God, I took a bus and got terrified just when I was in the middle of the crowd, I saw, mostly half of them had their masks on. I was getting more scared and already started remembering God. One of the Lady sitting in the front seat was talking to her mother, asking that br...

What is DevOps and what should I learn? - Aniruddha Banerjee - Medium

The most necessary and well-discussed topic was, why should I learn DevOps….. Most of the tech guys like me prefer to introduce myself as a Scrum specialist, Agile developer or maybe the latest term “Fullstack Developer”. Well, what I want to say that, all these impressive adjectives are basically referring to those who work within the periphery of DevOps. DevOps is Dev(development) and Ops(operation), that we all know. We know that it’s a culture, but when the question arises, what should I learn, become a DevOps cultured geek, I found myself into tons of Certifications, billions of tools, trillions of methodologies. Not a joke, but if you fall under a situation like me, when Corporate pushing me to become DevOps cultured, but I feared about Exams(it’s a childhood phobia I adopted :P), rather practically implement something worthy, or at least tried it, I became aware at the end that, this someone already had achieved, I should try something new. To study DevOps, I think, i...