help-cfengine
[Top][All Lists]
Advanced

[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

Hello,

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/mod_log_sql.so
LoadModule log_sql_mysql_module modules/mod_log_sql_mysql.so
LogSQLLoginInfo mysql://my:login@mysqlclust1/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:

editfiles:
                { /etc/httpd/conf.d/log_sql.conf
                        Backup "off"
                        AutoCreate
                        DefineClasses "httpd_restart"
                        BeginGroupIfNoLineMatching ".*LogSQLLoginInfo.*"
                        Append "LoadModule log_sql_module
modules/mod_log_sql.so"
                        Append "LoadModule log_sql_mysql_module
modules/mod_log_sql_mysql.so"
                        Append "LogSQLLoginInfo
mysql://my:login@mysqlclust1/apachelogs"
                        Append "LogSQLCreateTables on"
                        Append "LogSQLMassVirtualHosting On"
                        Append "LogSQLTransferLogFormat AabHhMmRrSsTUuv"
                        Append "LogSQLMachineID $(short_hostname)"
                        EndGroup
                }

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.

Thanks,

viraj.




reply via email to

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