I'm trying to get a basic templating system working for several files,
and expand_scalars doesn't seem to work. I've found serveral references
to other people having success with this, so I assume I've done
something wrong. I'm running the cfengine 3.0.3 community RPM build.
Here's the basic code:
bundle agent tmpl {
vars:
hostname::
"varA" string => "This is value Alpha";
"varB" string => "This is value Bravo";
files:
hostname::
"/tmp/template"
copy_from => update_copy("${g.repo}/template",${g.policy_server});
"/tmp/expanded"
create => 'true',
edit_defaults => empty,
edit_line => expand_template("/tmp/template");
}
Both 'empty' and 'expand_template come from cfengine_stdlib.cf file
posted a few days ago.
The content of the 'template' file is simply two lines:
The first variable: ${varA}
And the second: ${varB}
I expect, after the expansion is done to have a file that looks like
this:
The first variable: This is value Alpha
And the second: This is value Bravo
But alas, the two files are identical after running cf-agent.
Below is the relevant output from --verbose. The template file copies
over without problems, and the 'expanded' file is created, but no
interpolation appears to be done.
TIA,
cf3 Promise made by: /tmp/template
cf3 .........................................................
cf3
cf3 -> Copy file /tmp/template from
/usr/local/cfengine3/data/Packages/template check
... <snip>
cf3 -> /tmp/template wasn't at destination (copying)
... <snip>
cf3 -> New file /tmp/template.cfnew transmitted correctly - verified
... <snip>
cf3 .........................................................
cf3 Promise handle:
cf3 Promise made by: /tmp/expanded
cf3 .........................................................
cf3
cf3 -> Using literal pathtype for /tmp/expanded
cf3 -> No mode was set, choose plain file default 600
cf3 -> Created file /tmp/expanded, mode = 600
cf3 Build file model from a blank slate (emptying)
cf3 -> Handling file edits in edit_line bundle expand_template
cf3
cf3 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
cf3 BUNDLE expand_template( {'/tmp/template'} )
cf3 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
cf3
cf3 ? Augment scope expand_template with templatefile
cf3 ?? Private class context
cf3
cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3 insert_lines in bundle expand_template
cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3
cf3 .........................................................
cf3 Promise handle:
cf3 Promise made by: /tmp/template
cf3 .........................................................
cf3
cf3 -> Inserting the promised line "The first variable: ${varA}" into
/tmp/expanded after locator
cf3 -> Inserting the promised line "And the second: ${varB}" into
/tmp/expanded after locator
cf3 ?? Private class context
cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3 insert_lines in bundle expand_template
cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3
cf3
cf3 .........................................................
cf3 Promise handle:
cf3 Promise made by: /tmp/template
cf3 .........................................................
cf3
cf3 -> This promise has already been verified
cf3 ?? Private class context
cf3
cf3
cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3 insert_lines in bundle expand_template
cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
cf3
cf3
cf3 .........................................................
cf3 Promise handle:
cf3 Promise made by: /tmp/template
cf3 .........................................................
cf3
cf3 -> This promise has already been verified
cf3 -> Saving edit changes to file /tmp/expanded
cf3 Edited file /tmp/expanded
--
Jesse Becker
NHGRI Linux support (Digicon Contractor)
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine