How I’m editing a file with Cfengine2 on a solaris 10 client
Since cfengine 2 doesn’t seem to recognize ‘solaris’ as a OS class, I had to make separate groups for my solaris boxes, one for x86, one for all solaris and one for sun4. So that’s the reason for the object labels I have.
I’m still struggling with regex in Cfengine 2, but making progress.
I’m finally able to edit a file and make it convergent.
nextgenSolaris::
{
/etc/default/passwd
BeginGroupIfNoLineContaining “^MAXWEEKS=7″
ReplaceAll “MAXWEEKS=.*” With “MAXWEEKS=7″
EndGroup
BeginGroupIfNoLineContaining “^PASSLENGTH=8″
ReplaceAll “PASSLENGTH=.*” With “PASSLENGTH=8″
EndGroup
BeginGroupIfNoLineContaining “^HISTORY=12″
ReplaceAll “.*HISTORY=.*” With “HISTORY=12″
EndGroup
BeginGroupIfNoLineContaining “^MINALPHA=1″
ReplaceAll “.*MINALPHA=.*” With “MINALPHA=1″
EndGroup
BeginGroupIfNoLineContaining “^MINSPECIAL=1″
ReplaceAll “.*MINSPECIAL=.*” With “MINSPECIAL=1″
EndGroup
BeginGroupIfNoLineContaining “^MINDIGIT=1″
ReplaceAll “.*MINDIGIT=.*” With “MINDIGIT=1″
EndGroup
}
Notice the last two ReplaceAll statements. The regex starts with ‘.*’ meaning ‘starting with 1 character (.) followed by zero or more characters (*) until the plaintext pattern (MINDIGIT)’.