The rants and musing of Mike Gracy.

Brain dumps from a sysadmin

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)’.

Adventures in CFEngine.

I’m currently teaching myself CFengine 2 for use at work. So far I’ve bee pretty annoyed with it even though it’s language syntax is pretty straight forward, it’s handling of white space and requirements for new lines isn’t. 

Example:

editfiles:

    redhat::

{

 <– new line here or the following statements fail!

ReplaceAll “^PASS_MAX_DAYS” With “PASS_MAX_DAYS 35″

ReplaceAll “^PASS_MIN_DAYS” With “PASS_MIN_DAYS 0″

} <– New line not needed here, wtf?!?

 

Hello world!

Why did I start this? Why not.

Upon occasion I will brain dump stuff I am working on, mainly just to document what I did so I can find it later on. This may range from geeky new things in the SysAdmin world to new music I’m writing to something I am building in the back yard or in the work shed. I could also just post a recipe for cookies! :-P

Mike.

Post Navigation

Follow

Get every new post delivered to your Inbox.