On Tue, 5 Jul 2011 18:11:37 +0200 (CEST) zzamboni wrote:
n> I think to define an empty list you need to use the cf_null constant:
n> http://cfengine.com/manuals/cf3-reference.html#Special-list-value-cf_005fnull
Ah, thank you. I had not noticed that one.
n> OTOH, what is it exactly you want to do? Usually by looking at the
n> higher-level goal we might be able to suggest different ways to
n> achieve it.
I have a list of host routes and network routes that go in the same
file. They generate different lines (`route' invocations, really) in
Debian.
So in my editing bundle I take a list of hosts (a.b.c.d) and a list of
networks (a.b.c.d/e) and insert different lines for each type. I could
pass a single list and distinguish based on a pattern match of the
current item, but that seems more fragile to me than explicitly
separating the two different kinds of things. Thus I need either the
network list or the host list empty most of the time, which is where
cf_null was helpful. Below is the editing bundle.
Thanks
Ted
#+begin_src cfengine3
bundle edit_line edit_route(interface, partition, router, destination,
host_destination)
{
insert_lines:
redhat::
"# added by cfengine" comment => "Tag the file";
"$(destination) via $(router) dev $(interface).$(partition)";
"$(host_destination) via $(router) dev $(interface).$(partition)";
debian::
"#!/bin/sh";
"# added by cfengine" comment => "Tag the file";
"#";
"/sbin/route add -net $(destination) gw $(router) dev
$(interface).$(partition)";
"/sbin/route add -host $(host_destination) gw $(router) dev
$(interface).$(partition)";
}
#+end_src
Ted
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine