Hi,We're using module only when with have to interact with something that cannot be interacted with in a standard CFEngine way (command execution, file edition, etc), but only to read values, not to change the status of the system (CFEngine can always do it)
For instance, to manage our routes, we do something like this : vars: # We define the arrays : "route[1]" string => "192.168.10.0"; "gateway[1]" string => "192.168.10.254"; "mask[1]" string => "255.255.255.0"; "action[1]" string => "require"; "routing_index" slist => getindices("route"); commands:# the module parse the output of the route command, and defines classes based on the output, and the action in parameter "${g.rudder_dependencies}/checkroute.pl $(route[$(routing_index)]) $(mask[$(routing_index)]) $(gateway[$(routing_index)]) $(routing_index) $(action[$(routing_index)]) linux"
contain => in_shell, module => "true", # actually modify the route"/sbin/route add -net $(route[$(routing_index)]) netmask $(mask[$(routing_index)]) gw $(gateway[$(routing_index)])"
contain => in_shell,ifvarclass => canonify("route_$(routing_index)_add"), classes => cf2_if_else("route_$(routing_index)_added", "route_$(routing_index)_add_failed");
"/sbin/route del -net $(route[$(routing_index)]) netmask $(mask[$(routing_index)]) gw $(gateway[$(routing_index)])"
contain => in_shell,ifvarclass => canonify("route_$(routing_index)_delete"), classes => cf2_if_else("route_$(routing_index)_deleted", "route_$(routing_index)_delete_failed");
And attached is the perl script, gzipped Hope it helps Nicolas CHARLES On 21/03/2012 03:53, Nick Anderson wrote:
I'm just curious. At what point do you decide a module is better than doing things natively?-- Sent from Kaiten Mail. Please excuse my brevity. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
checkroute.pl.gz
Description: GNU Zip compressed data
_______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine