Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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");
}
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.