[Top][All Lists]

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

editfiles methodology question

From: Viraj Alankar
Subject: editfiles methodology question
Date: Sun, 6 Nov 2005 12:55:18 -0500


I have a certain task that I'd like to do but not sure what the best
way to do it with cfengine. Any advice appreciated.

Let's say I want have a file /etc/httpd/conf.d/log_sql.conf that looks
like the following on a couple of servers:

LoadModule log_sql_module modules/
LoadModule log_sql_mysql_module modules/
LogSQLLoginInfo mysql://my:address@hidden/apachelogs
LogSQLCreateTables on
LogSQLMassVirtualHosting On
LogSQLTransferLogFormat AabHhMmRrSsTUuv
LogSQLMachineID $(short_hostname)

Now short_hostname should be replaced with a variable that I define:

short_hostname = ( ExecResult(/bin/hostname -s) )

So basically I have almost identical data in the file except for the
last line, which is specific to each host. Right now I'm using an
editfiles like the following:

                { /etc/httpd/conf.d/log_sql.conf
                        Backup "off"
                        DefineClasses "httpd_restart"
                        BeginGroupIfNoLineMatching ".*LogSQLLoginInfo.*"
                        Append "LoadModule log_sql_module
                        Append "LoadModule log_sql_mysql_module
                        Append "LogSQLLoginInfo
                        Append "LogSQLCreateTables on"
                        Append "LogSQLMassVirtualHosting On"
                        Append "LogSQLTransferLogFormat AabHhMmRrSsTUuv"
                        Append "LogSQLMachineID $(short_hostname)"

But the problem is this does not really enforce the file always being
the same. I want to distribute it from cfengine if those first 6 lines
ever change. If the file isn't there I'd like it to be created and
httpd restarted. I don't think I could do a copy: because the checksum
will always be different with the short_hostname variable. If I do
that and then an editfiles: afterwards, it seems I would always be
restarting httpd.



reply via email to

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