help-cfengine
[Top][All Lists]
Advanced

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

Editing Files In Particular Format


From: Christopher Browne
Subject: Editing Files In Particular Format
Date: 18 Oct 2003 01:40:38 GMT

They look like the following:

oxrs.epp.server.dbpool.driver=org.postgresql.Driver
oxrs.epp.server.dbpool.user=cbbrowne
oxrs.epp.server.dbpool.password=nottoosecret
oxrs.epp.server.dbpool.url=jdbc:postgresql://localhost:5432/cbbrowne-oxrsdb
oxrs.epp.server.dbpool.min=1
oxrs.epp.server.dbpool.max=10
oxrs.epp.server.dbpool.timeout=5
oxrs.epp.server.dbpool.uses=-1

What I would _like_ to do is to have a series of "editing assertions"
that would look something like the following:

DBPASSWORD = ( abc123 )  # in control section
DBUSER = ( cbbrowne )
editfiles: 
{ /opt/app/oxrs.properties:
  ModifyJavaEnvar (oxrs.epp.server.dbpool.password,$(DBPASSWORD))
  ModifyJavaEnvar (oxrs.epp.server.dbpool.user,$(DBUSER))
  # And a bunch more lines to update a whole host of properties
}

The notion being that this would change the third line to have a new
password value.  And a --dry-run would report that it was going to
change the line to that.

The nearest that I _seem_ to be able to get is to try to:
 a) Construct a DeleteLinesMatching request with a pretty hideous
    regex, and
 b) Have an AppendIfNoSuchLine with the "new value."

This is really quite NOT nice.

I could always write a program in some other language that would do
the work for me.  I don't _like_ that because it throws away the
benefits of the way cfengine can do 'dry runs' and report on what
configuration it changes.

Another possibility would be to put the file editing into one file,
and write a script (Perl?  Python?  Common Lisp?  N'import quoi?) that
does the gory transformations that turns 'structured' updates looking
like
  ModifyJavaEnvar (propertyname,newvalue)
into the gory regular expressions.

Has anyone tried doing this?  Any suggestions?
-- 
select 'cbbrowne' || '@' || 'acm.org';
http://www3.sympatico.ca/cbbrowne/rdbms.html
"If I  could find  a way to  get [Saddam  Hussein] out of  there, even
putting a  contract out on him,  if the CIA  still did that sort  of a
thing, assuming it ever did, I would be for it."  -- Richard M. Nixon


reply via email to

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