2

I have started running cfengine3, using cf-execd to schedule runs of cf-agent at the default interval of every 5 minutes.

cf-execd captures the output of cf-agent (which is run with the --inform option), storing the output in the $WORKDIR/outputs directory, and also emailing the result (but only if it differs to the last run). As you might imagine, with an output file every 5 minutes, this directory will quickly fill up with a large number of files, and it is expected that the user cleans up this directory.

I created a rule which will delete these output files that are more than 3 days old, however the problem this creates is every output will be different to the previous one (as a new file will be deleted each time), hence an email will be sent. So I go from lots of files in the outputs dir, to lots of emails in my inbox!

What I would really like is to suppress messages when certain promises are repaired, particularly the one which deletes files in the outputs directory. It would essentially negate the -I option for that promise only. Alternatively, if I could change the time boundary from being from 'now' to a fixed point (say every Wednesday), I could at least restrict the number of emails down to one a week.

Hamish Downer
  • 9,142
  • 6
  • 36
  • 49
aaa90210
  • 351
  • 6
  • 15

3 Answers3

3

It looks like you never got an answer to your question, so I'm posting this now in the spirit of "better late than never".

You asked:

What I would really like is to suppress messages when certain promises are repaired, particularly the one which deletes files in the outputs directory. It would essentially negate the -I option for that promise only.

As far as I know, it is not possible to negate the --inform switch for a single promise.

Alternatively, if I could change the time boundary from being from 'now' to a fixed point (say every Wednesday), I could at least restrict the number of emails down to one a week.

This can be achieved using the "ifelapsed" parameter - this gives a minimum frequency with which to run a promise. Consider this example:

bundle agent garbage_collection {     
    files:
        "$(sys.workdir)/outputs" 
            delete => tidy,
            file_select => days_old("3"),
            depth_search => recurse("inf"),
            action => weekly;
}

body action weekly {
    ifelapsed => 10080; # one week, ie (60*24*7) minutes
}

Or you could just run this promise on Wednesdays, using the special class. I prefer the ifelapsed approach, which doesn't rely on a weekday (you never know if that host might not be running one Wednesday...), like this:

bundle agent garbage_collection {     
    files:
        Wednesday::
            "$(sys.workdir)/outputs" 
                delete => tidy,
                file_select => days_old("3"),
                depth_search => recurse("inf");
}
Jonathan Clarke
  • 1,657
  • 2
  • 11
  • 25
0

Actually I came to an even simpler answer - don't run cf-agent with --inform.

Just let cf-engine do it's thing and don't try and keep track of what repairs are being made, the main concern is the system has arrived in a desired state, not how it got there.

This may seem an anathema to a change management regime that wants to track every change to the system in excruciating detail, however I have found it is the only mindset that allows one to use cf-engine whilst remaining sane.

Of course, your answer was strictly the correct one to the question I posed, which is why I ticked it.

aaa90210
  • 351
  • 6
  • 15
0

In my 'inherited' deployment, I found that there was a garbage_collection bundle already in site.cf, but it was not called from anywhere. I need to add it the bundle sequence in promises.cf

Not sure if this would be the case in a new deployment; if so, you perhaps need to update your promises (I know I need to)

Hope it helps, Cameron

Cameron Kerr
  • 3,919
  • 18
  • 24