Forum: CFEngine Help
Subject: Improving community open promise-body library (COPBL)
Author: toddnni
Link to topic: https://cfengine.com/forum/read.php?3,24119,24119#msg-24119
Dear community,
I would like to share you some bodys that I miss from cfengine_stdlib.cf. I
think that most of us have created local libraries, but I tried to pick the
most general bodys.
###################################################
# edit_line bundles
###################################################
##
## editing bodies
##
body select_region in_between(start, end)
{
select_start => "$(start)";
select_end => "$(end)";
}
##
body select_region in_between_with_limiters(start, end)
{
select_start => "$(start)";
include_start_delimiter => "true";
select_end => "$(end)";
include_end_delimiter => "true";
}
##
## location
##
body location before_first(lineexp)
{
select_line_matching => "$(lineexp)";
before_after => "before";
first_last => "first";
}
##
body location before_last(lineexp)
{
select_line_matching => "$(lineexp)";
before_after => "before";
first_last => "last";
}
##
body location after_first(lineexp)
{
select_line_matching => "$(lineexp)";
before_after => "after";
first_last => "first";
}
##
body location after_last(lineexp)
{
select_line_matching => "$(lineexp)";
before_after => "after";
first_last => "last";
}
####################################################
## agent bodyparts
####################################################
##
## action
##
body action inform
{
report_level => "inform";
}
###################################################
# agent bundles
###################################################
##..................................................
## files promises
##..................................................
##
## copy_from
##
body copy_from local_bincp(path)
{
source => "$(path)";
compare => "binary";
}
##
body copy_from no_backup_scp(path, servers)
{
servers => { "@(servers)" };
source => "$(path)";
compare => "digest";
verify => "true";
encrypt => "true";
copy_backup => "false";
}
##
body copy_from no_backup_rdcp(path, servers)
{
servers => { "@(servers)" };
source => "$(path)";
compare => "digest";
copy_backup => "false";
}
##
## perms
##
body perms mg(mode, group)
{
groups => { "$(group)" };
mode => "$(mode)";
}
##
## file_select
##
body file_select by_path(paths)
{
path_name => { "@(paths)" };
file_result => "path_name";
}
##
body file_select exclude_path(paths)
{
path_name => { "@(paths)" };
file_result => "!path_name";
}
##
body file_select exclude_type(types)
{
file_types => { "@(types)" };
file_result => "!file_types";
}
##..................................................
## reports promises
##..................................................
##
## printfile
##
body printfile print_file(file, lines)
{
file_to_print => "$(file)";
number_of_lines => "$(lines)";
}
What do you think about these? Do you regard these general enough to be
included in the standard library?
Thanks for your time.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine