help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Editfiles logic question


From: Chip Seraphine
Subject: Editfiles logic question
Date: Wed, 03 Sep 2003 11:02:40 -0500
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.2.1) Gecko/20030721


Question for you zen masters of editfiles out there....

I am interested in finding out if any lines of my vfstab file contain the word "ufs" but do NOT contain the word "logging"; if so, I will define the class "FileHasUnloggedLines".

I am hampered by the lack of a BeginGroupIfMatch to go with the BeginGroupIfNoMatch (or at least a groupelse type thingie) and the inability to undefine classes.

        ForEachLineIn "/tmp/vfstab"
                #Ignore if the line contains "logging"
                BeginGroupIfNoMatch "^.*\blogging\b.*$"
                        #Ignore if we have "ufs" in the line
                        BeginGroupIfNoMatch "^.*\bufs\b.*$"
                                DefineInGroup "no_ufs_in_line"
                        EndGroup

                        BeginGroupIfNotDefined "no_ufs_in_line"
                                DefineInGroup "FileHasUnloggedLines"
                                #undefine no_ufs_in_line here
                        EndGroup
                EndGroup
        EndLoop


The above does not work because once no_ufs_in_line is set, it stays set; a subsequent line cannot unset it, so the bottom group will never fire if the first line seen contains "logging" and/or does not contain "ufs".

Is there an easier way to do this within the editfiles syntax? Or am I completely barking up the wrong tree?

It would be easy enough to just schedule a periodic RunScript that has a perl or python script scan for the appropriate lines, but I am hoping to do this convergently (i.e. within cfengine).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]