Below you will find pages that have the tag “copbl”
Editing whitespace-separated config files with cfengine
August 25, 2010
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sets the RHS of configuration items in the file of the form | |
# LHS RHS | |
# If the line is commented out with #, it gets uncommented first. | |
# Adds a new line if none exists. | |
# The argument is an associative array containing v[LHS]="rhs" | |
# Based on set_variable_values from cfengine_stdlib.cf, modified | |
# by Diego Zamboni to use whitespace as separator, and to handle | |
# commented-out lines. | |
bundle edit_line set_config_values(v) | |
{ | |
vars: | |
"index" slist => getindices("$(v)"); | |
# Be careful if the index string contains funny chars | |
"cindex[$(index)]" string => canonify("$(index)"); | |
field_edits: | |
# If the line is there, but commented out, first uncomment it | |
"#+$(index)\s+.*" | |
edit_field => col("\s+","1","$(index)","set"); | |
# match a line starting like the key something | |
"$(index)\s+.*" | |
edit_field => col("\s+","2","$($(v)[$(index)])","set"), | |
classes => if_ok("not_$(cindex[$(index)])"); | |
insert_lines: | |
"$(index) $($(v)[$(index)])", | |
ifvarclass => "!not_$(cindex[$(index)])"; | |
} |
cfengine Community Open Promise Body Library on GitHub
August 25, 2010
I have created a copy of the cfengine COPBL on GitHub , where I will use it as a playground for changes and additions. This is in no way endorsed by cfengine - it is just my personal copy. But if you use GitHub and want to use it, go ahead, I will try to keep it updated with respect to the original subversion repository , although it will include my changes too.