You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# cf-agent --bundlesequence example_basename --no-lock --log-level info --file /home/nickanderson/src/presentations/state-of-the-cfengine/cfengine3-NiK6sU
info: Using command line specified bundlesequence
R: basename = 'cfengine3-NiK6sU'
R: basename without '.cf' extension = 'cfengine3-NiK6sU'
classfiltercsv()
New in 3.15.0
Useful to reduce logic and speed policy
classfiltercsv() Input
ClassExpr,Sort,Token,Value
# This is a comment
any,A,net.ipv4.ip_forward,ANYVALUE
example_class1,z,net.ipv4.ip_forward,ANYVALUE
example_class2,a,net.ipv4.ip_forward,127.0.0.3
not_defined,Z,net.ipv4.ip_forward,NOT_DEFINED
example_class3.example_class2.example_class1,1,net.ipv4.ip_forward,127.0.0.4
also_undefined,0,net.ipv4.ip_forward,NOT_DEFINED
NOTE: CRLF (Windows/DOS) line endings required per RFC
Checkout Jay Goldberg’s talk “Data-Driven Configuration with CFEngine’s classfiltercsv function” tomorrow, 16:50–17:15, B.2.009
hash_to_int()
New in 3.12.0
Useful for distributed grouping and orchestration (re-implement select_class)
bundle agent example_hash_to_int
{
vars:
"hello" int => hash_to_int(0, 1000, "hello");
"world" int => hash_to_int(0, 1000, "world");
# Hash can vary on hostkey or policy hub:
"hour" int => hash_to_int(0, 24, "$(sys.key_digest)");
"minute" int => hash_to_int(0, 60, "$(sys.policy_hub)");
reports:
"'hello' hashed to: $(hello)";
"'world' hashed to: $(world)";
}
info: Using command line specified bundlesequence
R: 'hello' hashed to: 172
R: 'world' hashed to: 760
string_replace()
New in 3.12.1
Convenience, more simple version of regex_replace()
bundle agent example_string_replace
{
vars:
"my_string" string => "This is not the string you are looking for";
reports:
"$(with)" with => string_replace( $(my_string), "not ", "" );
}
R: This is the string you are looking for
read_module_protocol()
New in 3.15.0
Useful for leveraging cached output from module protocol
More light weight and less noisy than using cat
read_module_protocol() Example usage
bundle agent cache_maintenance
# Creates a module protocol cache, refreshes it if minute is 30-35
{
vars:
"file"
string => "$(this.promise_dirname)/cached_module";
classes:
"cache_refresh"
if => not(fileexists("$(file)"));
Min30_35::
"cache_refresh";
files:
cache_refresh::
"$(file)"
create => "true",
template_method => "inline_mustache",
edit_template_string => "=my_variable=$(sys.date)";
}
read_module_protocol() Example usage continued …
bundle agent demo
# Demonstrates read_module_protocol function, prints a variable from it
{
classes:
"cache_was_read"
if => read_module_protocol("$(cache_maintenance.file)");
reports:
cache_was_read::
"Module cache was read!";
"cached_module.my_variable = $(cached_module.my_variable)";
}
bundle agent __main__
{
methods:
"cache_maintenance"
handle => "cache_maintenance_done";
"demo"
depends_on => { "cache_maintenance_done" };
}
R: Module cache was read!
R: cached_module.my_variable = Mon Feb 3 05:32:05 2020
read_module_protocol() Example output
R: Module cache was read!
R: cached_module.my_variable = Mon Feb 3 05:32:05 2020
body copy_from missing_ok
New in 3.12.0
Promise KEPT if source file is missing (except for remote
Useful for opportunistic copies (host specific data)
info: Executing 'no timeout' ... '/bin/false'
error: Finished command related to promiser '/bin/false' -- an error occurred, returned 1
info: Completed execution of '/bin/false'
info: Created file '/tmp/now.txt', mode 0600
R: /tmp/now.txt
Multiple augments
New in 3.12.0
Multiple augments: def.json
{
"vars": {
"my_var": "This is my_var, set in def.json",
"my_platform_specific_var": "This is my_platform_specific_var, set in def.json"
},
"augments": [ "$(sys.flavor).json" ]
}
Multiple augments: $(sys.flavor).json
{
"vars": {
"my_platform_specific_var": "This is my_platform_specific_var, set in ubuntu_19.json"
}
}
Multiple augments: policy
bundle agent main
{
reports:
"$(sys.flavor)";
"$(def.my_var)";
"$(def.my_platform_specific_var)";
}
Multiple augments: Policy run and output
cf-agent -KIf ./example.cf
R: ubuntu_19
R: This is my_var, set in def.json
R: This is my_platform_specific_var, set in ubuntu_19.json
Augments classes by class expression
New in 3.14.0, 3.12.2
Improved CI
Valgrind
ASAM
LGTM
Enterprise
Federated Reporting
Policy Analyzer
Alert conditions
File changes
Custom SQL
Dashboard widgets
Newly bootstrapped hosts trend
Decommissioned hosts trend
Improved report builder
Extend with custom schema
File integrity monitoring UI
Fine grained permissions for RBAC
Export/Import settings
APIs
Inventory
File changes
New OOTB Inventory
AWS EC2 region, instance type, instance id, availability zone
System UUID
Setuid files
Root owned setuid files
Tooling
cf-remote
Install CFEngine on remote hosts, provision vms on cloud providers
cf-check
Validate and repair lmdbs
cf-bottom
Tom, the new cfengine team member, triggers builds in jenkins
???
Thank you
Made with spacemacs, using org-mode, ob-cfengine3, and org-reveal, with love