help-cfengine
[Top][All Lists]
Advanced

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

ExpandVariables patch for the editfiles section


From: Davor Ocelic
Subject: ExpandVariables patch for the editfiles section
Date: Mon, 18 Jul 2005 23:06:53 +0200

Hello,

Allow me to inform you of the simple ExpandVariables patch
(for the editfiles section) that performs expansion of variables in the
input file to the values of correspondingly named cfengine variables.

http://colt.projectgamma.com/cfengine/cfengine-2.1.15-variable-expansion.patch

I have no deep cfengine knowledge, so any suggestions/corrections are welcome.


My primary motive for coding it was the need to use templates with cfengine.
As I envisioned it, in the update phase, templates would be transferred to the
client along with other data. In the normal run, templates would then be copied 
to 
another location, variable-expanded and edited as appropriate, and finally 
copied to their local destination.


PATCH NOTES:
- The function does not allow escaping of $() or ${} in input files to prevent
  unintended expansion - all recognized variables are expanded. (You can, 
however,
  count on cfengine's behavior of passing non-existing variables through 
verbatim).

- I wanted to make a function which would operate on a single line, but didn't 
find
  a convenient existing method to loop over all lines in a file manually. 
Therefore,
  the function scans and expands the whole file itself.

- Buffer size for expansion is of length CF_EXPANDSIZE. Is this sensible, given 
that
  both the static (invariant) and "dynamic" (expanded) part of the line must 
fit in
  that buffer for the function to succeed?

- It appears that a function in editfiles is not triggered unless it is 
accompanyed
  by an argument. So even though ExpandVariables does not use any arguments, 
you need
  to call  ExpandVariables ''  to trigger it. Does this fit the general logic?


Best regards,
-doc




reply via email to

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