From cf94915d903fac8cff2f986d08d3ef97d9d41faa Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Tue, 16 Jun 2026 02:02:04 +0200 Subject: [PATCH 01/10] GH Actions: Added cfengine format --check Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit 5db150be882c03ea24a9a95b1dcf531324ee7bb2) --- .github/workflows/formatting.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index a33813b16..cf533554e 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -20,7 +20,10 @@ jobs: run: | npm install --global prettier pipx install cfengine black - - name: Run formatting command to (hopefully not) make changes + - name: Run cfengine format --check + run: | + cfengine format --check + - name: Run cfengine dev format-docs to (hopefully not) make changes run: | cfengine dev format-docs - name: Check if there are changes From 60ded0c38c295fab420da37db5a17d3b282a9168 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Tue, 16 Jun 2026 02:02:37 +0200 Subject: [PATCH 02/10] GH Actions: Renamed formatting to lint-and-format Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit 17b8a9f6862a43fcfc618f556505437dfa223e64) --- .github/workflows/{formatting.yml => lint-and-format.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{formatting.yml => lint-and-format.yml} (97%) diff --git a/.github/workflows/formatting.yml b/.github/workflows/lint-and-format.yml similarity index 97% rename from .github/workflows/formatting.yml rename to .github/workflows/lint-and-format.yml index cf533554e..ec3b825f9 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/lint-and-format.yml @@ -1,4 +1,4 @@ -name: Check formatting +name: Lint and format on: [push, pull_request] From 9c45b9d0f57ea2bd0f99b3fc5b759c8f37f3f8f0 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Tue, 16 Jun 2026 01:04:39 +0200 Subject: [PATCH 03/10] Removed unnecessary separator comments Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit 61f26a09c44386c80f877c181745e06613b8471c) --- .../example-snippets/aborting_execution.cf | 3 -- .../example-snippets/acl_file_example.cf | 4 --- .../example-snippets/acl_generic_example.cf | 3 -- .../example-snippets/acl_secret_example.cf | 3 -- .../active_directory_example.cf | 3 -- .../example-snippets/add_lines_to_a_file.cf | 1 - .../example-snippets/add_lines_to_a_file_1.cf | 1 - .../add_software_packages_to_the_system.cf | 1 - .../example-snippets/all_hosts_the_same.cf | 4 --- .../example-snippets/application_baseline.cf | 4 --- .../back_references_in_filenames.cf | 6 ---- .../example-snippets/change_detection.cf | 1 - .../change_directory_for_command.cf | 1 - .../check_filesystem_space.cf | 1 - .../example-snippets/class_match_example.cf | 1 - .../example-snippets/client-server_example.cf | 13 --------- .../commenting_lines_in_a_file.cf | 24 ---------------- .../copy_and_flatten_directory.cf | 13 --------- .../create_files_and_directories.cf | 8 ------ .../example-snippets/custom_editing_1.cf | 5 ---- .../example-snippets/database_creation.cf | 1 - .../deleting_lines_exception.cf | 6 ---- .../deleting_lines_from_a_file.cf | 5 ---- .../distribute_root_passwords.cf | 8 ------ .../example-snippets/distribute_ssh_keys.cf | 4 --- .../example-snippets/editing_files.cf | 5 ---- .../editing_password_or_group_files_custom.cf | 3 -- .../example-snippets/editing_tabular_files.cf | 9 ------ .../example-snippets/environment_variables.cf | 6 ---- .../environments_(virtual).cf | 7 ----- .../example-snippets/execresult_example.cf | 1 - .../example-snippets/get_a_list_of_users.cf | 5 ---- .../example-snippets/global_classes.cf | 8 ------ ...hashing_for_change_detection_(tripwire).cf | 5 ---- .../inserting_lines_in_a_file.cf | 24 ---------------- .../laptop_support_configuration.cf | 15 ---------- .../example-snippets/ldap_interactions.cf | 2 -- .../example-snippets/linking_files.cf | 15 ---------- .../listing_files-pattern_in_a_directory.cf | 1 - .../locate_and_transform_files.cf | 7 ----- .../examples/example-snippets/log_rotation.cf | 2 -- .../examples/example-snippets/measurements.cf | 12 -------- .../example-snippets/method_validation.cf | 3 -- content/examples/example-snippets/methods.cf | 2 -- .../example-snippets/mount_a_filesystem.cf | 1 - .../example-snippets/mount_nfs_filesystem.cf | 1 - .../example-snippets/ordering_promises.cf | 6 ---- .../postfix_mail_configuration.cf | 8 ------ .../example-snippets/process_management.cf | 28 ------------------- .../example-snippets/prune_processes.cf | 2 -- .../read_from_a_tcp_socket.cf | 1 - .../example-snippets/resolver_management.cf | 10 ------- .../example-snippets/restart_process.cf | 1 - .../example-snippets/restart_process_1.cf | 1 - .../search_and_replace_text.cf | 9 ------ .../selecting_a_region_in_a_file.cf | 5 ---- .../service_management_(windows).cf | 1 - .../set_up_a_pxe_boot_server.cf | 9 ------ .../example-snippets/set_up_a_web_server.cf | 6 ---- .../example-snippets/set_up_hpc_clusters.cf | 3 -- .../set_up_name_resolution.cf | 1 - .../software_and_patch_installation_1.cf | 2 -- .../software_and_patch_installation_1_2.cf | 1 - .../software_and_patch_installation_1_2_3.cf | 1 - .../example-snippets/software_distribution.cf | 7 ----- .../example-snippets/tidying_garbage_files.cf | 8 ------ .../example-snippets/trigger_classes.cf | 9 ------ .../unit_registry_cache.cf.cf | 2 -- .../unmount_nfs_filesystem.cf | 4 --- .../updating_from_a_central_hub.cf | 2 -- .../example-snippets/variation_in_hosts.cf | 4 --- .../warn_if_matching_line_in_file.cf | 7 ----- .../example-snippets/web_server_modules.cf | 7 ----- content/resources/additional-topics/STIGs.cf | 4 --- 74 files changed, 407 deletions(-) diff --git a/content/examples/example-snippets/aborting_execution.cf b/content/examples/example-snippets/aborting_execution.cf index c06104845..967e7336a 100644 --- a/content/examples/example-snippets/aborting_execution.cf +++ b/content/examples/example-snippets/aborting_execution.cf @@ -4,13 +4,11 @@ body common control version => "1.2.3"; } -########################################### body agent control { abortbundleclasses => { "invalid.Hr16" }; } -########################################### bundle agent testbundle { vars: @@ -21,7 +19,6 @@ bundle agent testbundle "any" usebundle => subtest("$(userlist)"); } -########################################### bundle agent subtest(user) { classes: diff --git a/content/examples/example-snippets/acl_file_example.cf b/content/examples/example-snippets/acl_file_example.cf index 6d4460931..d55fc91f9 100644 --- a/content/examples/example-snippets/acl_file_example.cf +++ b/content/examples/example-snippets/acl_file_example.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "acls" }; } -######################################### bundle agent acls { files: @@ -12,7 +11,6 @@ bundle agent acls acl => template; } -######################################### body acl template { acl_method => "overwrite"; @@ -23,7 +21,6 @@ body acl template }; } -######################################### body acl win { acl_method => "overwrite"; @@ -32,7 +29,6 @@ body acl win aces => { "user:Administrator:rw", "group:Bad:rwx(Dpo):deny" }; } -######################################### body depth_search include_base { include_basedir => "true"; diff --git a/content/examples/example-snippets/acl_generic_example.cf b/content/examples/example-snippets/acl_generic_example.cf index cf759a7a1..da50e18cb 100644 --- a/content/examples/example-snippets/acl_generic_example.cf +++ b/content/examples/example-snippets/acl_generic_example.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "acls" }; } -######################################### bundle agent acls { files: @@ -12,14 +11,12 @@ bundle agent acls acl => test; } -######################################### body acl test { acl_type => "generic"; aces => { "user:bob:rwx", "group:staff:rx", "all:r" }; } -######################################### body depth_search include_base { include_basedir => "true"; diff --git a/content/examples/example-snippets/acl_secret_example.cf b/content/examples/example-snippets/acl_secret_example.cf index 14955e5a0..da880be78 100644 --- a/content/examples/example-snippets/acl_secret_example.cf +++ b/content/examples/example-snippets/acl_secret_example.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "acls" }; } -######################################### bundle agent acls { files: @@ -14,14 +13,12 @@ bundle agent acls comment => "Secure the secret directory from unauthorized access"; } -######################################### body acl win { acl_method => "overwrite"; aces => { "user:Administrator:rwx" }; } -######################################### body depth_search include_base { include_basedir => "true"; diff --git a/content/examples/example-snippets/active_directory_example.cf b/content/examples/example-snippets/active_directory_example.cf index e3d277624..b54e8acad 100644 --- a/content/examples/example-snippets/active_directory_example.cf +++ b/content/examples/example-snippets/active_directory_example.cf @@ -1,12 +1,9 @@ -######################################################################### # active_directory.cf - Extract Data From Windows Domain Controllers # # NOTE: Since we don't supply any credentials in this policy file, # the Domain Controller must allow anonymous bind. Also, # the user "NT AUTHORITY\ANONYMOUS LOGON" must be granted access # to the resources we want to read. -# -######################################################################### bundle agent active_directory { vars: diff --git a/content/examples/example-snippets/add_lines_to_a_file.cf b/content/examples/example-snippets/add_lines_to_a_file.cf index 7a9c1194a..54224710c 100644 --- a/content/examples/example-snippets/add_lines_to_a_file.cf +++ b/content/examples/example-snippets/add_lines_to_a_file.cf @@ -4,7 +4,6 @@ body common control bundlesequence => { "insert" }; } -####################################################### bundle agent insert { vars: diff --git a/content/examples/example-snippets/add_lines_to_a_file_1.cf b/content/examples/example-snippets/add_lines_to_a_file_1.cf index 2df7b6192..1d4674cc4 100644 --- a/content/examples/example-snippets/add_lines_to_a_file_1.cf +++ b/content/examples/example-snippets/add_lines_to_a_file_1.cf @@ -4,7 +4,6 @@ body common control bundlesequence => { "insert" }; } -####################################################### bundle agent insert { vars: diff --git a/content/examples/example-snippets/add_software_packages_to_the_system.cf b/content/examples/example-snippets/add_software_packages_to_the_system.cf index 3124b35d4..f8bd7da64 100644 --- a/content/examples/example-snippets/add_software_packages_to_the_system.cf +++ b/content/examples/example-snippets/add_software_packages_to_the_system.cf @@ -4,7 +4,6 @@ body common control bundlesequence => { "packages" }; } -############################################# bundle agent packages { vars: diff --git a/content/examples/example-snippets/all_hosts_the_same.cf b/content/examples/example-snippets/all_hosts_the_same.cf index b30b1ede3..f834c5b79 100644 --- a/content/examples/example-snippets/all_hosts_the_same.cf +++ b/content/examples/example-snippets/all_hosts_the_same.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "central" }; } -############################################ bundle agent central { vars: @@ -27,9 +26,7 @@ bundle agent central # Add more promises below ... } -######################################################### # Server config -######################################################### body server control { allowconnects => { "127.0.0.1", "::1", "10.20.30.0/24" }; @@ -38,7 +35,6 @@ body server control # allowusers } -######################################################### bundle server my_access_rules() { access: diff --git a/content/examples/example-snippets/application_baseline.cf b/content/examples/example-snippets/application_baseline.cf index 50d20b30d..a8c9f7fa4 100644 --- a/content/examples/example-snippets/application_baseline.cf +++ b/content/examples/example-snippets/application_baseline.cf @@ -1,13 +1,9 @@ -######################################################################### -# # app_baseline.cf - Verify Existence of Applications # # NOTE: Sometimes applications are not correctly installed even # though the native package manager reports them to be. # CFEngine can check for application-specific configuration # and act upon or report any anomalies. -# -######################################################################### bundle agent app_baseline { methods: diff --git a/content/examples/example-snippets/back_references_in_filenames.cf b/content/examples/example-snippets/back_references_in_filenames.cf index 3f3fe74e2..46d5d0cfd 100644 --- a/content/examples/example-snippets/back_references_in_filenames.cf +++ b/content/examples/example-snippets/back_references_in_filenames.cf @@ -1,15 +1,10 @@ -###################################################################### -# # File editing - back reference -# -###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { files: @@ -23,7 +18,6 @@ bundle agent testbundle # edit_line => myedit("second $(match.1)"); } -######################################################## bundle edit_line myedit(parameter) { vars: diff --git a/content/examples/example-snippets/change_detection.cf b/content/examples/example-snippets/change_detection.cf index bb9918aa6..31dc31e4e 100644 --- a/content/examples/example-snippets/change_detection.cf +++ b/content/examples/example-snippets/change_detection.cf @@ -4,7 +4,6 @@ body common control inputs => { "cfengine_stdlib.cf" }; } -######################################################## bundle agent testbundle { files: diff --git a/content/examples/example-snippets/change_directory_for_command.cf b/content/examples/example-snippets/change_directory_for_command.cf index d50b9430a..31de93f7a 100644 --- a/content/examples/example-snippets/change_directory_for_command.cf +++ b/content/examples/example-snippets/change_directory_for_command.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "example" }; } -########################################################### body contain cd(dir) { chdir => "${dir}"; diff --git a/content/examples/example-snippets/check_filesystem_space.cf b/content/examples/example-snippets/check_filesystem_space.cf index cb36f6437..7054f6d1f 100644 --- a/content/examples/example-snippets/check_filesystem_space.cf +++ b/content/examples/example-snippets/check_filesystem_space.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "example" }; } -########################################################### bundle agent example { vars: diff --git a/content/examples/example-snippets/class_match_example.cf b/content/examples/example-snippets/class_match_example.cf index dc47a5cc3..ba1b88f65 100644 --- a/content/examples/example-snippets/class_match_example.cf +++ b/content/examples/example-snippets/class_match_example.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "example" }; } -########################################################### bundle agent example { classes: diff --git a/content/examples/example-snippets/client-server_example.cf b/content/examples/example-snippets/client-server_example.cf index d5c84bd69..071dbcd6e 100644 --- a/content/examples/example-snippets/client-server_example.cf +++ b/content/examples/example-snippets/client-server_example.cf @@ -1,16 +1,11 @@ -######################################################## -# # Simple test copy from server connection to cfServer # -######################################################## -# # run this as follows: # # cf-serverd -f runtest_1.cf [-v] # cf-agent -f runtest_2.cf # # Notice that the same file configures all parts of cfengine -######################################################## body common control { bundlesequence => { "testbundle" }; @@ -18,7 +13,6 @@ body common control #fips_mode => "true"; } -######################################################## bundle agent testbundle { files: @@ -41,19 +35,16 @@ bundle agent testbundle "Files were copied.."; } -######################################################### body perms system { mode => "0644"; } -######################################################### body depth_search recurse(d) { depth => "$(d)"; } -######################################################### body copy_from mycopy(from, server) { source => "$(from)"; @@ -69,16 +60,13 @@ body copy_from mycopy(from, server) trustkey => "true"; } -######################################################### body classes satisfied(x) { promise_repaired => { "$(x)" }; persist_time => "0"; } -######################################################### # Server config -######################################################### body server control { allowconnects => { "127.0.0.1", "::1" }; @@ -87,7 +75,6 @@ body server control # allowusers } -######################################################### bundle server my_access_rules() { access: diff --git a/content/examples/example-snippets/commenting_lines_in_a_file.cf b/content/examples/example-snippets/commenting_lines_in_a_file.cf index a8b9e9a31..18e3e38fe 100644 --- a/content/examples/example-snippets/commenting_lines_in_a_file.cf +++ b/content/examples/example-snippets/commenting_lines_in_a_file.cf @@ -1,13 +1,9 @@ -###################################################################### -# # File editing # # Normal ordering: # - delete # - replace | column_edit # - insert -# -###################################################################### body common control { version => "1.2.3"; @@ -15,7 +11,6 @@ body common control bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { files: @@ -24,7 +19,6 @@ bundle agent testbundle edit_line => myedit("second"); } -######################################################## bundle edit_line myedit(parameter) { vars: @@ -37,9 +31,7 @@ bundle edit_line myedit(parameter) select_region => MySection("New section"); } -######################################## # Bodies -######################################## body replace_with C_comment { # backreference 0: @@ -48,25 +40,19 @@ body replace_with C_comment occurrences => "all"; } -######################################################## body select_region MySection(x) { select_start => "\[$(x)\]"; select_end => "\[.*\]"; } -###################################################################### -# # Comment lines -# -###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { files: @@ -75,7 +61,6 @@ bundle agent testbundle edit_line => comment_lines_matching; } -######################################################## bundle edit_line comment_lines_matching { vars: @@ -85,20 +70,14 @@ bundle edit_line comment_lines_matching "^($(regexes))$" replace_with => comment("# "); } -######################################## # Bodies -######################################## body replace_with comment(c) { replace_value => "$(c) $(match.1)"; occurrences => "all"; } -###################################################################### -# # Uncomment lines -# -###################################################################### body common control { version => "1.2.3"; @@ -110,7 +89,6 @@ body common control # two # mark one #mark two -######################################################## bundle agent testbundle { files: @@ -119,14 +97,12 @@ bundle agent testbundle edit_line => uncomment_lines_matching("\s*mark.*", "#"); } -######################################################## bundle edit_line uncomment_lines_matching(regex, comment) { replace_patterns: "#($(regex))$" replace_with => uncomment; } -######################################################## body replace_with uncomment { replace_value => "$(match.1)"; diff --git a/content/examples/example-snippets/copy_and_flatten_directory.cf b/content/examples/example-snippets/copy_and_flatten_directory.cf index 9593f160f..13f5a303a 100644 --- a/content/examples/example-snippets/copy_and_flatten_directory.cf +++ b/content/examples/example-snippets/copy_and_flatten_directory.cf @@ -1,23 +1,17 @@ -######################################################## -# # Simple test copy from server connection to cfServer # -######################################################## -# # run this as follows: # # cf-serverd -f runtest_1.cf [-d2] # cf-agent -f runtest_2.cf # # Notice that the same file configures all parts of cfengine -######################################################## body common control { bundlesequence => { "testbundle" }; version => "1.2.3"; } -######################################################## bundle agent testbundle { files: @@ -40,19 +34,16 @@ bundle agent testbundle "Files were copied.."; } -######################################################### body perms system { mode => "0644"; } -######################################################### body depth_search recurse(d) { depth => "$(d)"; } -######################################################### body copy_from mycopy(from, server) { source => "$(from)"; @@ -68,16 +59,13 @@ body copy_from mycopy(from, server) collapse_destination_dir => "true"; } -######################################################### body classes satisfied(x) { promise_repaired => { "$(x)" }; persist_time => "0"; } -######################################################### # Server config -######################################################### body server control { allowconnects => { "127.0.0.1", "::1" }; @@ -85,7 +73,6 @@ body server control trustkeysfrom => { "127.0.0.1", "::1" }; } -######################################################### bundle server my_access_rules() { access: diff --git a/content/examples/example-snippets/create_files_and_directories.cf b/content/examples/example-snippets/create_files_and_directories.cf index 11996e376..7f85c0e68 100644 --- a/content/examples/example-snippets/create_files_and_directories.cf +++ b/content/examples/example-snippets/create_files_and_directories.cf @@ -1,14 +1,9 @@ -######################################################## -# # Simple test create files -# -######################################################## body common control { bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { files: @@ -21,10 +16,7 @@ bundle agent testbundle create => "true"; } -######################################################### body perms system { mode => "0640"; } - -######################################################### diff --git a/content/examples/example-snippets/custom_editing_1.cf b/content/examples/example-snippets/custom_editing_1.cf index 6cdbb6fbb..8a4977e8a 100644 --- a/content/examples/example-snippets/custom_editing_1.cf +++ b/content/examples/example-snippets/custom_editing_1.cf @@ -1,14 +1,9 @@ -####################################################### -# # Edit variable = value in a text file -# -####################################################### body common control { bundlesequence => { "testsetvar" }; } -####################################################### bundle agent testsetvar { vars: diff --git a/content/examples/example-snippets/database_creation.cf b/content/examples/example-snippets/database_creation.cf index 58b58d4c1..f3dadfd5f 100644 --- a/content/examples/example-snippets/database_creation.cf +++ b/content/examples/example-snippets/database_creation.cf @@ -36,7 +36,6 @@ bundle agent databases database_server => myserver; } -################################################ body database_server myserver { none:: diff --git a/content/examples/example-snippets/deleting_lines_exception.cf b/content/examples/example-snippets/deleting_lines_exception.cf index 4744612e3..490d2f6f0 100644 --- a/content/examples/example-snippets/deleting_lines_exception.cf +++ b/content/examples/example-snippets/deleting_lines_exception.cf @@ -1,9 +1,5 @@ -######################################################## -# # Simple test editfile # -######################################################## -# # This assumes a file format like: # # [section 1] @@ -18,7 +14,6 @@ body common control bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { files: @@ -27,7 +22,6 @@ bundle agent testbundle edit_line => mark_n_root; } -######################################################## bundle edit_line mark_n_root { delete_lines: diff --git a/content/examples/example-snippets/deleting_lines_from_a_file.cf b/content/examples/example-snippets/deleting_lines_from_a_file.cf index b4efa1734..3747ebf4f 100644 --- a/content/examples/example-snippets/deleting_lines_from_a_file.cf +++ b/content/examples/example-snippets/deleting_lines_from_a_file.cf @@ -13,9 +13,7 @@ bundle agent test edit_defaults => def; } -####################################################### # For the library -####################################################### bundle edit_line resolver { vars: @@ -29,7 +27,6 @@ bundle edit_line resolver "$(search)" location => end; } -####################################################### body edit_defaults def { empty_file_before_editing => "false"; @@ -37,14 +34,12 @@ body edit_defaults def max_file_size => "100000"; } -######################################################## body location start { # If not line to match, applies to whole text body before_after => "before"; } -######################################################## body location end { # If not line to match, applies to whole text body diff --git a/content/examples/example-snippets/distribute_root_passwords.cf b/content/examples/example-snippets/distribute_root_passwords.cf index 0abed523d..3e65107eb 100644 --- a/content/examples/example-snippets/distribute_root_passwords.cf +++ b/content/examples/example-snippets/distribute_root_passwords.cf @@ -1,8 +1,4 @@ -###################################################################### -# # Root password distribution -# -###################################################################### body common control { version => "1.2.3"; @@ -10,14 +6,12 @@ body common control bundlesequence => { "set_root_password" }; } -######################################################## bundle common g { vars: "secret_keys_dir" string => "/tmp"; } -######################################################## bundle agent set_root_password { vars: @@ -36,7 +30,6 @@ bundle agent set_root_password "/tmp/shadow" edit_line => set_root_password; } -######################################################## bundle edit_line set_root_password { vars: @@ -53,7 +46,6 @@ bundle edit_line set_root_password edit_field => col(":", "2", "$(rpw[root][1])", "set"); } -######################################################## bundle server passwords { vars: diff --git a/content/examples/example-snippets/distribute_ssh_keys.cf b/content/examples/example-snippets/distribute_ssh_keys.cf index 156ec976a..41c464d3e 100644 --- a/content/examples/example-snippets/distribute_ssh_keys.cf +++ b/content/examples/example-snippets/distribute_ssh_keys.cf @@ -8,8 +8,6 @@ # methods: # # "any" usebundle => allow_ssh_login_from_authorized_keys(@(users),"sourcehost"); -# -######################################################################## bundle agent allow_ssh_rootlogin_from_authorized_keys(user, sourcehost) { vars: @@ -33,7 +31,6 @@ bundle agent allow_ssh_rootlogin_from_authorized_keys(user, sourcehost) action => if_elapsed("60"); } -######################################################################## bundle agent allow_ssh_login_from_authorized_keys(user, sourcehost) { vars: @@ -57,7 +54,6 @@ bundle agent allow_ssh_login_from_authorized_keys(user, sourcehost) action => if_elapsed("60"); } -######################################################################## bundle edit_line insert_file_if_no_line_matching(user, file) { classes: diff --git a/content/examples/example-snippets/editing_files.cf b/content/examples/example-snippets/editing_files.cf index e64b2b08b..1c1a2d8e8 100644 --- a/content/examples/example-snippets/editing_files.cf +++ b/content/examples/example-snippets/editing_files.cf @@ -1,8 +1,4 @@ -###################################################################### -# # Comment lines -# -###################################################################### body common control { version => "1.2.3"; @@ -10,7 +6,6 @@ body common control inputs => { "$(sys.libdir)/stdlib.cf" }; } -######################################################## bundle agent testbundle { vars: diff --git a/content/examples/example-snippets/editing_password_or_group_files_custom.cf b/content/examples/example-snippets/editing_password_or_group_files_custom.cf index abafee481..75b50a816 100644 --- a/content/examples/example-snippets/editing_password_or_group_files_custom.cf +++ b/content/examples/example-snippets/editing_password_or_group_files_custom.cf @@ -17,9 +17,7 @@ bundle agent addpasswd edit_line => append_users_starting("addpasswd.pwd"); } -############################################################ # Library stuff -############################################################ bundle edit_line append_users_starting(v) { vars: @@ -32,7 +30,6 @@ bundle edit_line append_users_starting(v) "$($(v)[$(index)])" if => "add_$(index)"; } -############################################################ bundle edit_line append_groups_starting(v) { vars: diff --git a/content/examples/example-snippets/editing_tabular_files.cf b/content/examples/example-snippets/editing_tabular_files.cf index c65cf4bb5..1df4d8169 100644 --- a/content/examples/example-snippets/editing_tabular_files.cf +++ b/content/examples/example-snippets/editing_tabular_files.cf @@ -1,20 +1,15 @@ -###################################################################### -# # File editing # # Normal ordering: # - delete # - replace | column_edit # - insert -# -###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { vars: @@ -34,7 +29,6 @@ bundle agent testbundle "/bin/echo" args => $(userset); } -######################################################## bundle edit_line set_user_param(user, field, val) { field_edits: @@ -43,7 +37,6 @@ bundle edit_line set_user_param(user, field, val) edit_field => col(":", "$(field)", "$(val)", "set"); } -######################################################## bundle edit_line append_user_param(user, field, allusers) { vars: @@ -55,9 +48,7 @@ bundle edit_line append_user_param(user, field, allusers) edit_field => col(":", "$(field)", "$(val)", "alphanum"); } -######################################## # Bodies -######################################## body edit_field col(split, col, newval, method) { field_separator => $(split); diff --git a/content/examples/example-snippets/environment_variables.cf b/content/examples/example-snippets/environment_variables.cf index 4cb5b8b99..727335253 100644 --- a/content/examples/example-snippets/environment_variables.cf +++ b/content/examples/example-snippets/environment_variables.cf @@ -1,14 +1,9 @@ -####################################################### -# # Virtual environments -# -####################################################### body common control { bundlesequence => { "my_vm_cloud" }; } -####################################################### bundle agent my_vm_cloud { environments: @@ -20,7 +15,6 @@ bundle agent my_vm_cloud # default environment_state => "create" on host, and "suspended elsewhere" } -####################################################### body environment_resources virt_xml { env_spec_file => "/srv/xen/centos5-libvirt-create.xml"; diff --git a/content/examples/example-snippets/environments_(virtual).cf b/content/examples/example-snippets/environments_(virtual).cf index c0d031be2..292573108 100644 --- a/content/examples/example-snippets/environments_(virtual).cf +++ b/content/examples/example-snippets/environments_(virtual).cf @@ -1,14 +1,9 @@ -####################################################### -# # Virtual environments -# -####################################################### body common control { bundlesequence => { "my_vm_cloud" }; } -####################################################### bundle agent my_vm_cloud { vars: @@ -26,13 +21,11 @@ bundle agent my_vm_cloud # default environment_state => "create" on host, and "suspended elsewhere" } -####################################################### body environment_resources virt_xml(specfile) { env_spec_file => "$(specfile)"; } -####################################################### body environment_interface vnet(primary) { env_name => "$(this.promiser)"; diff --git a/content/examples/example-snippets/execresult_example.cf b/content/examples/example-snippets/execresult_example.cf index c0a66db8c..39c443254 100644 --- a/content/examples/example-snippets/execresult_example.cf +++ b/content/examples/example-snippets/execresult_example.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "example" }; } -########################################################### bundle agent example { vars: diff --git a/content/examples/example-snippets/get_a_list_of_users.cf b/content/examples/example-snippets/get_a_list_of_users.cf index 68a1734d8..1560f6c93 100644 --- a/content/examples/example-snippets/get_a_list_of_users.cf +++ b/content/examples/example-snippets/get_a_list_of_users.cf @@ -1,14 +1,9 @@ -####################################################### -# # GetUsers -# -####################################################### body common control { bundlesequence => { test }; } -####################################################### bundle agent test { vars: diff --git a/content/examples/example-snippets/global_classes.cf b/content/examples/example-snippets/global_classes.cf index 55b67c6c9..2c591a33f 100644 --- a/content/examples/example-snippets/global_classes.cf +++ b/content/examples/example-snippets/global_classes.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "g", "tryclasses_1", "tryclasses_2" }; } -################################# bundle common g { classes: @@ -11,14 +10,12 @@ bundle common g "client_network" expression => iprange("128.39.89.0/24"); } -################################# bundle agent tryclasses_1 { classes: "two" expression => "any"; } -################################# bundle agent tryclasses_2 { classes: @@ -35,7 +32,6 @@ body common control bundlesequence => { "g", "tryclasses_1", "tryclasses_2" }; } -################################# bundle common g { classes: @@ -43,14 +39,12 @@ bundle common g "client_network" expression => iprange("128.39.89.0/24"); } -################################# bundle agent tryclasses_1 { classes: "two" expression => "any"; } -################################# bundle agent tryclasses_2 { classes: @@ -60,5 +54,3 @@ bundle agent tryclasses_2 one.three.!two:: "Success"; } - -################################# diff --git a/content/examples/example-snippets/hashing_for_change_detection_(tripwire).cf b/content/examples/example-snippets/hashing_for_change_detection_(tripwire).cf index 92058b9c3..15eb91ae8 100644 --- a/content/examples/example-snippets/hashing_for_change_detection_(tripwire).cf +++ b/content/examples/example-snippets/hashing_for_change_detection_(tripwire).cf @@ -1,15 +1,10 @@ -######################################################## -# # Change detect -# -######################################################## body common control { bundlesequence => { "testbundle" }; inputs => { "$(sys.libdir)/stdlib.cf" }; } -######################################################## bundle agent testbundle { files: diff --git a/content/examples/example-snippets/inserting_lines_in_a_file.cf b/content/examples/example-snippets/inserting_lines_in_a_file.cf index bf892f569..473cd5f2a 100644 --- a/content/examples/example-snippets/inserting_lines_in_a_file.cf +++ b/content/examples/example-snippets/inserting_lines_in_a_file.cf @@ -1,15 +1,10 @@ -####################################################### -# # Insert a number of lines with vague whitespace -# -####################################################### body common control { any:: bundlesequence => { "insert" }; } -####################################################### bundle agent insert { vars: @@ -21,33 +16,25 @@ bundle agent insert edit_line => insert_name("$(insert.v)"); } -####################################################### # For the library -####################################################### bundle edit_line insert_name(name) { insert_lines: " $(name)" whitespace_policy => { "ignore_leading", "ignore_embedded" }; } -####################################################### body edit_defaults empty { empty_file_before_editing => "true"; } -####################################################### -# # Insert a number of lines -# -####################################################### body common control { any:: bundlesequence => { "insert" }; } -####################################################### bundle agent insert { vars: @@ -66,33 +53,25 @@ bundle agent insert edit_defaults => empty; } -####################################################### # For the library -####################################################### bundle edit_line insert_name(name) { insert_lines: "Begin$(const.n)$(name)$(const.n)End"; } -####################################################### body edit_defaults empty { empty_file_before_editing => "false"; } -####################################################### -# # Insert a number of lines -# -####################################################### body common control { any:: bundlesequence => { "insert" }; } -####################################################### bundle agent insert { vars: @@ -106,16 +85,13 @@ bundle agent insert # edit_defaults => empty; } -####################################################### # For the library -####################################################### bundle edit_line insert_name(name) { insert_lines: "$(name)"; } -####################################################### body edit_defaults empty { empty_file_before_editing => "true"; diff --git a/content/examples/example-snippets/laptop_support_configuration.cf b/content/examples/example-snippets/laptop_support_configuration.cf index cbaf305ae..6b6190f9a 100644 --- a/content/examples/example-snippets/laptop_support_configuration.cf +++ b/content/examples/example-snippets/laptop_support_configuration.cf @@ -1,28 +1,21 @@ -####################################################### -# # Laptop -# -####################################################### body common control { bundlesequence => { "update", "garbage_collection", "main", "backup" }; inputs => { "update.cf", "site.cf", "library.cf" }; } -####################################################### body agent control { # if default runtime is 5 mins we need this for long jobs ifelapsed => "15"; } -####################################################### body monitor control { forgetrate => "0.7"; } -####################################################### body executor control { splaytime => "1"; @@ -33,15 +26,12 @@ body executor control exec_command => "$(sys.workdir)/bin/cf-agent -f failsafe.cf && $(sys.workdir)/bin/cf-agent"; } -####################################################### # General site issues can be in bundles like this one -####################################################### bundle agent main { vars: "component" slist => { "cf-monitord", "cf-serverd" }; - # - - - - - - - - - - - - - - - - - - - - - - - - files: "$(sys.resolv)" # test on "/tmp/resolv.conf" # @@ -52,15 +42,12 @@ bundle agent main processes: "$(component)" restart_class => canonify("$(component)_not_running"); - # - - - - - - - - - - - - - - - - - - - - - - - - commands: "$(sys.workdir)/bin/$(component)" if => canonify("$(component)_not_running"); } -####################################################### # Backup -####################################################### bundle agent backup { files: @@ -71,9 +58,7 @@ bundle agent backup action => longjob; } -####################################################### # Garbage collection issues -####################################################### bundle agent garbage_collection { files: diff --git a/content/examples/example-snippets/ldap_interactions.cf b/content/examples/example-snippets/ldap_interactions.cf index af136173b..edef983c4 100644 --- a/content/examples/example-snippets/ldap_interactions.cf +++ b/content/examples/example-snippets/ldap_interactions.cf @@ -3,11 +3,9 @@ body common control bundlesequence => { "ldap", "followup" }; } -################################################################################################### # NOTE!! relying on LDAP or other network data without validation is EXTREMELY dangerous. # You could destroy a system by assuming that the service will respond with a # sensible result. CFEngine does not recommend reliance on network services in configuration. -################################################################################################### bundle agent ldap { vars: diff --git a/content/examples/example-snippets/linking_files.cf b/content/examples/example-snippets/linking_files.cf index 6414a5370..ff79487bc 100644 --- a/content/examples/example-snippets/linking_files.cf +++ b/content/examples/example-snippets/linking_files.cf @@ -1,20 +1,15 @@ -###################################################################### -# # File editing # # Normal ordering: # - delete # - replace | column_edit # - insert -# -###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { files: @@ -26,7 +21,6 @@ bundle agent testbundle "/home/mark/tmp/linktest" link_from => linkchildren("/usr/local/sbin"); } -######################################################### body link_from linkdetails(tofile) { source => "$(tofile)"; @@ -35,7 +29,6 @@ body link_from linkdetails(tofile) when_no_source => "force"; } -######################################################### body link_from linkchildren(tofile) { source => "$(tofile)"; @@ -46,18 +39,13 @@ body link_from linkchildren(tofile) when_linking_children => "if_no_such_file"; } -####################################################### -# # Test dead link removal -# -####################################################### body common control { any:: bundlesequence => { "testbundle" }; } -############################################ bundle agent testbundle { files: @@ -67,20 +55,17 @@ bundle agent testbundle action => tell_me; } -############################################ body depth_search recurse(d) { rmdeadlinks => "true"; depth => "$(d)"; } -############################################ body perms modestuff { mode => "o-w"; } -############################################ body action tell_me { report_level => "inform"; diff --git a/content/examples/example-snippets/listing_files-pattern_in_a_directory.cf b/content/examples/example-snippets/listing_files-pattern_in_a_directory.cf index db817a91d..ba1c439b1 100644 --- a/content/examples/example-snippets/listing_files-pattern_in_a_directory.cf +++ b/content/examples/example-snippets/listing_files-pattern_in_a_directory.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "example" }; } -########################################################### bundle agent example { vars: diff --git a/content/examples/example-snippets/locate_and_transform_files.cf b/content/examples/example-snippets/locate_and_transform_files.cf index 6f210a3ba..a2a9ef883 100644 --- a/content/examples/example-snippets/locate_and_transform_files.cf +++ b/content/examples/example-snippets/locate_and_transform_files.cf @@ -1,8 +1,4 @@ -####################################################### -# # Compressing files -# -####################################################### body common control { any:: @@ -10,7 +6,6 @@ body common control version => "1.2.3"; } -############################################ bundle agent testbundle { files: @@ -20,14 +15,12 @@ bundle agent testbundle depth_search => recurse("inf"); } -############################################ body file_select pdf_files { leaf_name => { ".*.pdf", ".*.fdf" }; file_result => "leaf_name"; } -############################################ body depth_search recurse(d) { depth => "$(d)"; diff --git a/content/examples/example-snippets/log_rotation.cf b/content/examples/example-snippets/log_rotation.cf index 9473b62f1..54863a410 100644 --- a/content/examples/example-snippets/log_rotation.cf +++ b/content/examples/example-snippets/log_rotation.cf @@ -3,14 +3,12 @@ body common control bundlesequence => { "testbundle" }; } -############################################ bundle agent testbundle { files: "/home/mark/tmp/rotateme" rename => rotate("4"); } -############################################ body rename rotate(level) { rotate => "$(level)"; diff --git a/content/examples/example-snippets/measurements.cf b/content/examples/example-snippets/measurements.cf index c0cf24196..029415193 100644 --- a/content/examples/example-snippets/measurements.cf +++ b/content/examples/example-snippets/measurements.cf @@ -1,25 +1,20 @@ #cop measurements,example -####################################################### # # Test file: # # First line # Blonk blonk bnklkygsuilnm -# -####################################################### body common control { bundlesequence => { "report" }; } -####################################################### body monitor control { forgetrate => "0.7"; histograms => "true"; } -####################################################### bundle agent report { reports: @@ -29,7 +24,6 @@ bundle agent report "; } -####################################################### bundle monitor watch { measurements: @@ -75,41 +69,35 @@ bundle monitor watch history_type => "log"; } -########################################################## body match_value scanlines(x) { select_line_matching => "^$(x)$"; } -########################################################## body action sample_min(x) { ifelapsed => $(x); expireafter => $(x); } -########################################################## body match_value find_blonks { select_line_number => "2"; extraction_regex => "Blonk blonk ([blonk]+).*"; } -########################################################## body match_value free_memory { select_line_matching => "MemFree:.*"; extraction_regex => "MemFree:\s+([0-9]+).*"; } -########################################################## body match_value proc_value(x, y) { select_line_matching => $(x); extraction_regex => $(y); } -########################################################## body match_value file_system { select_line_matching => "/.*"; diff --git a/content/examples/example-snippets/method_validation.cf b/content/examples/example-snippets/method_validation.cf index 3a4987d85..7bd4cd3e0 100644 --- a/content/examples/example-snippets/method_validation.cf +++ b/content/examples/example-snippets/method_validation.cf @@ -4,13 +4,11 @@ body common control version => "1.2.3"; } -########################################### body agent control { abortbundleclasses => { "invalid" }; } -########################################### bundle agent testbundle { vars: @@ -21,7 +19,6 @@ bundle agent testbundle "any" usebundle => subtest("$(userlist)"); } -########################################### bundle agent subtest(user) { classes: diff --git a/content/examples/example-snippets/methods.cf b/content/examples/example-snippets/methods.cf index d03fcea6d..0a19ff757 100644 --- a/content/examples/example-snippets/methods.cf +++ b/content/examples/example-snippets/methods.cf @@ -4,7 +4,6 @@ body common control version => "1.2.3"; } -########################################### bundle agent testbundle { vars: @@ -14,7 +13,6 @@ bundle agent testbundle "any" usebundle => subtest("$(userlist)"); } -########################################### bundle agent subtest(user) { commands: diff --git a/content/examples/example-snippets/mount_a_filesystem.cf b/content/examples/example-snippets/mount_a_filesystem.cf index 2246750e2..bbe47fde2 100644 --- a/content/examples/example-snippets/mount_a_filesystem.cf +++ b/content/examples/example-snippets/mount_a_filesystem.cf @@ -12,7 +12,6 @@ bundle agent mounts "/mnt" mount => nfs("slogans.iu.hio.no", "/home"); } -###################################################################### body mount nfs(server, source) { mount_type => "nfs"; diff --git a/content/examples/example-snippets/mount_nfs_filesystem.cf b/content/examples/example-snippets/mount_nfs_filesystem.cf index 2246750e2..bbe47fde2 100644 --- a/content/examples/example-snippets/mount_nfs_filesystem.cf +++ b/content/examples/example-snippets/mount_nfs_filesystem.cf @@ -12,7 +12,6 @@ bundle agent mounts "/mnt" mount => nfs("slogans.iu.hio.no", "/home"); } -###################################################################### body mount nfs(server, source) { mount_type => "nfs"; diff --git a/content/examples/example-snippets/ordering_promises.cf b/content/examples/example-snippets/ordering_promises.cf index d736650e4..d89036a0f 100644 --- a/content/examples/example-snippets/ordering_promises.cf +++ b/content/examples/example-snippets/ordering_promises.cf @@ -1,18 +1,13 @@ -################################################################## -# # cfengine 3 - ordering promises into dependent chains # ## # # cf-agent -f ./cftest.cf -K -# -################################################################## body common control { bundlesequence => { "order" }; } -################################################################## bundle agent order { vars: @@ -34,7 +29,6 @@ bundle agent order "/bin/echo seven"; } -############################################ body classes d(if, else) { promise_repaired => { "$(if)" }; diff --git a/content/examples/example-snippets/postfix_mail_configuration.cf b/content/examples/example-snippets/postfix_mail_configuration.cf index ee26b1fda..f3c73f00c 100644 --- a/content/examples/example-snippets/postfix_mail_configuration.cf +++ b/content/examples/example-snippets/postfix_mail_configuration.cf @@ -1,15 +1,10 @@ -####################################################### -# # Postfix -# -####################################################### body common control { inputs => { "$(sys.libdir)/stdlib.cf" }; bundlesequence => { postfix }; } -####################################################### bundle agent postfix { vars: @@ -28,9 +23,7 @@ bundle agent postfix ); } -####################################################### # For the library -####################################################### bundle edit_line prefix_postfix { # Value have the form NAME = "quoted space separated list" @@ -53,7 +46,6 @@ bundle edit_line prefix_postfix "$(parameter_name) = $(ps[$(parameter_name)])"; } -######################################################## bundle edit_line append_if_nsl(parameter) { insert_lines: diff --git a/content/examples/example-snippets/process_management.cf b/content/examples/example-snippets/process_management.cf index 275a131d3..1e05ce3a4 100644 --- a/content/examples/example-snippets/process_management.cf +++ b/content/examples/example-snippets/process_management.cf @@ -9,17 +9,12 @@ bundle agent test "sleep" signals => { "term", "kill" }; } -######################################################## -# # Simple test processes -# -######################################################## body common control { bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { processes: @@ -30,7 +25,6 @@ bundle agent testbundle "Out of control"; } -######################################################## body process_count up(s) { match_range => "5,10"; @@ -38,17 +32,12 @@ body process_count up(s) out_of_range_define => { "$(s)_out_of_control" }; } -######################################################## -# # Simple test processes -# -######################################################## body common control { bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { processes: @@ -57,7 +46,6 @@ bundle agent testbundle process_count => up("cfservd"); } -######################################################## body process_count up(s) { match_range => "1,10"; @@ -65,24 +53,18 @@ body process_count up(s) out_of_range_define => { "$(s)_out_of_control" }; } -######################################################## body process_select proc_finder(p) { stime_range => irange(ago("0", "0", "0", "2", "0", "0"), now); process_result => "stime"; } -######################################################## -# # Simple test processes -# -######################################################## body common control { bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { processes: @@ -91,7 +73,6 @@ bundle agent testbundle process_count => up("cfservd"); } -######################################################## body process_count up(s) { match_range => "1,10"; @@ -99,7 +80,6 @@ body process_count up(s) out_of_range_define => { "$(s)_out_of_control" }; } -######################################################## body process_select proc_finder(p) { process_owner => { "avahi", "bin" }; @@ -114,7 +94,6 @@ body common control bundlesequence => { "process_restart" }; } -######################################################### bundle agent process_restart { processes: @@ -130,7 +109,6 @@ body common control bundlesequence => { "process_restart" }; } -######################################################### bundle agent process_restart { vars: @@ -143,17 +121,12 @@ bundle agent process_restart "/var/cfengine/bin/$(component)" if => canonify("$(component)_not_running"); } -######################################################## -# # Simple test process restart -# -######################################################## body common control { bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { processes: @@ -169,7 +142,6 @@ bundle agent testbundle "/usr/local/sbin/cfservd"; } -######################################################## body process_count up(s) { match_range => "1,10"; diff --git a/content/examples/example-snippets/prune_processes.cf b/content/examples/example-snippets/prune_processes.cf index 5bceb01d8..9685ac732 100644 --- a/content/examples/example-snippets/prune_processes.cf +++ b/content/examples/example-snippets/prune_processes.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { processes: @@ -12,7 +11,6 @@ bundle agent testbundle signals => { "term" }; } -######################################################## body process_select big_processes(o) { process_owner => { $(o) }; diff --git a/content/examples/example-snippets/read_from_a_tcp_socket.cf b/content/examples/example-snippets/read_from_a_tcp_socket.cf index cf66f1364..c08b099a1 100644 --- a/content/examples/example-snippets/read_from_a_tcp_socket.cf +++ b/content/examples/example-snippets/read_from_a_tcp_socket.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "example" }; } -########################################################### bundle agent example { vars: diff --git a/content/examples/example-snippets/resolver_management.cf b/content/examples/example-snippets/resolver_management.cf index b65f843d3..216ec739a 100644 --- a/content/examples/example-snippets/resolver_management.cf +++ b/content/examples/example-snippets/resolver_management.cf @@ -1,8 +1,4 @@ -####################################################### -# # Resolve conf -# -####################################################### bundle common g # globals { @@ -15,7 +11,6 @@ bundle common g expression => reglist("@(nameservers)", "$(sys.ipv4[eth1])"); } -####################################################### body common control { any:: @@ -23,7 +18,6 @@ body common control domain => "iu.hio.no"; } -####################################################### bundle agent resolver(s, n) { files: @@ -38,9 +32,7 @@ bundle agent resolver(s, n) # or edit_defaults => modify } -####################################################### # For the library -####################################################### bundle edit_line doresolv(s, n) { vars: @@ -50,7 +42,6 @@ bundle edit_line doresolv(s, n) "$(line)"; } -####################################################### body edit_defaults reconstruct { empty_file_before_editing => "true"; @@ -58,7 +49,6 @@ body edit_defaults reconstruct max_file_size => "100000"; } -####################################################### body edit_defaults modify { empty_file_before_editing => "false"; diff --git a/content/examples/example-snippets/restart_process.cf b/content/examples/example-snippets/restart_process.cf index ffa4f1ca5..3565cc068 100644 --- a/content/examples/example-snippets/restart_process.cf +++ b/content/examples/example-snippets/restart_process.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "process_restart" }; } -######################################################### bundle agent process_restart { processes: diff --git a/content/examples/example-snippets/restart_process_1.cf b/content/examples/example-snippets/restart_process_1.cf index c47bf58a0..763f0c331 100644 --- a/content/examples/example-snippets/restart_process_1.cf +++ b/content/examples/example-snippets/restart_process_1.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "process_restart" }; } -######################################################### bundle agent process_restart { vars: diff --git a/content/examples/example-snippets/search_and_replace_text.cf b/content/examples/example-snippets/search_and_replace_text.cf index c788a5ac2..948d1a500 100644 --- a/content/examples/example-snippets/search_and_replace_text.cf +++ b/content/examples/example-snippets/search_and_replace_text.cf @@ -1,20 +1,15 @@ -###################################################################### -# # File editing # # Normal ordering: # - delete # - replace | column_edit # - insert -# -###################################################################### body common control { version => "1.2.3"; bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { files: @@ -23,7 +18,6 @@ bundle agent testbundle edit_line => myedit("second"); } -######################################################## bundle edit_line myedit(parameter) { vars: @@ -34,16 +28,13 @@ bundle edit_line myedit(parameter) "puppet" replace_with => With("cfengine 3"); } -######################################## # Bodies -######################################## body replace_with With(x) { replace_value => $(x); occurrences => "first"; } -######################################## body select_region MySection(x) { select_start => "\[$(x)\]"; diff --git a/content/examples/example-snippets/selecting_a_region_in_a_file.cf b/content/examples/example-snippets/selecting_a_region_in_a_file.cf index 2c4f2dc10..624808ea7 100644 --- a/content/examples/example-snippets/selecting_a_region_in_a_file.cf +++ b/content/examples/example-snippets/selecting_a_region_in_a_file.cf @@ -4,7 +4,6 @@ body common control bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { files: @@ -13,7 +12,6 @@ bundle agent testbundle edit_line => myedit("second"); } -######################################################## bundle edit_line myedit(parameter) { vars: @@ -26,9 +24,7 @@ bundle edit_line myedit(parameter) select_region => ToEnd("Start.*"); } -######################################## # Bodies -######################################## body replace_with comment { replace_value => "# $(match.1)"; @@ -37,7 +33,6 @@ body replace_with comment # first, last all } -######################################################## body select_region ToEnd(x) { select_start => $(x); diff --git a/content/examples/example-snippets/service_management_(windows).cf b/content/examples/example-snippets/service_management_(windows).cf index e5eaf1c0a..87fe925b1 100644 --- a/content/examples/example-snippets/service_management_(windows).cf +++ b/content/examples/example-snippets/service_management_(windows).cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "winservice" }; } -########################################################### bundle agent winservice { vars: diff --git a/content/examples/example-snippets/set_up_a_pxe_boot_server.cf b/content/examples/example-snippets/set_up_a_pxe_boot_server.cf index 2e3dda78d..4e53257ae 100644 --- a/content/examples/example-snippets/set_up_a_pxe_boot_server.cf +++ b/content/examples/example-snippets/set_up_a_pxe_boot_server.cf @@ -399,37 +399,31 @@ enable=1 classes => satisfied("packages_ok"); } -##################################################### ########### *** Bodies are here *** ################# -##################################################### body file_select pxelinux_files { leaf_name => { "pxelinux.0" }; file_result => "leaf_name"; } -##################################################### body copy_from mycopy_local(from, server) { source => "$(from)"; compare => "digest"; } -######################################################### body link_from mylink(x) { source => "$(x)"; link_type => "symlink"; } -####################################################### body classes satisfied(new_class) { promise_kept => { "$(new_class)" }; promise_repaired => { "$(new_class)" }; } -####################################################### bundle edit_line comment_lines_matching_apache2(comment) { vars: @@ -442,11 +436,8 @@ bundle edit_line comment_lines_matching_apache2(comment) "^($(regex))$" replace_with => comment("$(comment)"); } -####################################################### body file_select input_files { leaf_name => { ".*.cf", ".*.dat", ".*.txt" }; file_result => "leaf_name"; } - -####################################################### diff --git a/content/examples/example-snippets/set_up_a_web_server.cf b/content/examples/example-snippets/set_up_a_web_server.cf index d3cec9bc8..c15acfc04 100644 --- a/content/examples/example-snippets/set_up_a_web_server.cf +++ b/content/examples/example-snippets/set_up_a_web_server.cf @@ -1,8 +1,4 @@ -##################################################### -# # Apache webserver module -# -##################################################### bundle agent web_server(state) { vars: @@ -58,9 +54,7 @@ bundle agent web_server(state) "off" expression => strcmp("$(state)", "off"); } -####################################################### # For the library -####################################################### bundle edit_line fixapache { vars: diff --git a/content/examples/example-snippets/set_up_hpc_clusters.cf b/content/examples/example-snippets/set_up_hpc_clusters.cf index 2bc541899..f84d9fbb3 100644 --- a/content/examples/example-snippets/set_up_hpc_clusters.cf +++ b/content/examples/example-snippets/set_up_hpc_clusters.cf @@ -1,4 +1,3 @@ -####################################################### body executor control { splaytime => "1"; @@ -9,7 +8,6 @@ body executor control schedule => { "Min00" }; } -####################################################### bundle agent services_disable { vars: @@ -36,7 +34,6 @@ bundle agent services_disable "$(xinetd_services)" signals => { "kill" }; } -############################################################################### bundle agent disable_xinetd(name) { vars: diff --git a/content/examples/example-snippets/set_up_name_resolution.cf b/content/examples/example-snippets/set_up_name_resolution.cf index 37dbcf6ca..080b87aba 100644 --- a/content/examples/example-snippets/set_up_name_resolution.cf +++ b/content/examples/example-snippets/set_up_name_resolution.cf @@ -11,7 +11,6 @@ bundle agent system_files # ...other system files ... } -####################################################### bundle edit_line resolver { delete_lines: diff --git a/content/examples/example-snippets/software_and_patch_installation_1.cf b/content/examples/example-snippets/software_and_patch_installation_1.cf index d7c879876..b6f4f2bcb 100644 --- a/content/examples/example-snippets/software_and_patch_installation_1.cf +++ b/content/examples/example-snippets/software_and_patch_installation_1.cf @@ -4,7 +4,6 @@ body common control bundlesequence => { "packages" }; } -############################################# bundle agent packages { vars: @@ -19,7 +18,6 @@ bundle agent packages package_method => msi_vmatch; } -############################################# body package_method msi_vmatch { package_changes => "individual"; diff --git a/content/examples/example-snippets/software_and_patch_installation_1_2.cf b/content/examples/example-snippets/software_and_patch_installation_1_2.cf index 845ca8bc2..93f054797 100644 --- a/content/examples/example-snippets/software_and_patch_installation_1_2.cf +++ b/content/examples/example-snippets/software_and_patch_installation_1_2.cf @@ -5,7 +5,6 @@ body common control inputs => { "cfengine_stdlib.cf" }; } -############################################# bundle agent packages { vars: diff --git a/content/examples/example-snippets/software_and_patch_installation_1_2_3.cf b/content/examples/example-snippets/software_and_patch_installation_1_2_3.cf index 025986019..5001c29b6 100644 --- a/content/examples/example-snippets/software_and_patch_installation_1_2_3.cf +++ b/content/examples/example-snippets/software_and_patch_installation_1_2_3.cf @@ -5,7 +5,6 @@ body common control inputs => { "cfengine_stdlib.cf" } } -############################################# bundle agent packages { vars: diff --git a/content/examples/example-snippets/software_distribution.cf b/content/examples/example-snippets/software_distribution.cf index dcffcb054..1222b437e 100644 --- a/content/examples/example-snippets/software_distribution.cf +++ b/content/examples/example-snippets/software_distribution.cf @@ -1,5 +1,3 @@ -######################################################################### -# # software_local.cf - Application Deployment From Directory Repository # # NOTE: Windows needs to support WMI queries about installed msi files @@ -23,8 +21,6 @@ # For example, ProductName "CFEngine Nova" with ProductVersion # "1.1.2" for 32-bit Windows will correspond to the filename # "cfengine-nova-1.1.2-i686.msi". -# -######################################################################### bundle agent check_software { vars: @@ -44,7 +40,6 @@ bundle agent check_software # "any" usebundle => remove_software( "@(check_software.exclude_software)", "$(sys.policy_hub)" ); } -######################################################################### bundle agent add_software(pkg_name) { vars: @@ -76,7 +71,6 @@ bundle agent add_software(pkg_name) "Failed to install one or more packages"; } -######################################################################### bundle agent update_software(sw_names) { vars: @@ -112,7 +106,6 @@ bundle agent update_software(sw_names) "Failed to update one or more packages"; } -######################################################################### bundle agent remove_software(pkg_name) { vars: diff --git a/content/examples/example-snippets/tidying_garbage_files.cf b/content/examples/example-snippets/tidying_garbage_files.cf index e3c21db33..e403302a2 100644 --- a/content/examples/example-snippets/tidying_garbage_files.cf +++ b/content/examples/example-snippets/tidying_garbage_files.cf @@ -1,15 +1,10 @@ -####################################################### -# # Deleting files, like cf2 tidy age=0 r=inf -# -####################################################### body common control { any:: bundlesequence => { "testbundle" }; } -############################################ bundle agent testbundle { files: @@ -19,21 +14,18 @@ bundle agent testbundle depth_search => recurse("inf"); } -######################################################### body depth_search recurse(d) { #include_basedir => "true"; depth => "$(d)"; } -######################################################### body delete tidy { dirlinks => "delete"; rmdirs => "false"; } -######################################################### body file_select zero_age # we can build old "include", "exclude", and "ignore" # from these as standard patterns - these bodies can diff --git a/content/examples/example-snippets/trigger_classes.cf b/content/examples/example-snippets/trigger_classes.cf index b93a02ec2..2cbe4655b 100644 --- a/content/examples/example-snippets/trigger_classes.cf +++ b/content/examples/example-snippets/trigger_classes.cf @@ -1,15 +1,10 @@ -####################################################### -# # Insert a number of lines and trigger a followup if edited -# -####################################################### body common control { any:: bundlesequence => { "insert" }; } -####################################################### bundle agent insert { vars: @@ -36,22 +31,18 @@ bundle agent insert "The potatoes are bananas"; } -####################################################### # For the library -####################################################### bundle edit_line insert_name(name) { insert_lines: "Begin$(const.n) $(name)$(const.n)End"; } -####################################################### body edit_defaults empty { empty_file_before_editing => "true"; } -####################################################### body classes trigger(x) { promise_repaired => { $(x) }; diff --git a/content/examples/example-snippets/unit_registry_cache.cf.cf b/content/examples/example-snippets/unit_registry_cache.cf.cf index d03209ed0..316cce263 100644 --- a/content/examples/example-snippets/unit_registry_cache.cf.cf +++ b/content/examples/example-snippets/unit_registry_cache.cf.cf @@ -5,7 +5,6 @@ body common control }; } -######################################### bundle agent registry_cache { databases: @@ -16,7 +15,6 @@ bundle agent registry_cache comment => "Save correct registry settings for Adobe products"; } -######################################### bundle agent registry_restore { databases: diff --git a/content/examples/example-snippets/unmount_nfs_filesystem.cf b/content/examples/example-snippets/unmount_nfs_filesystem.cf index de5f0cce0..b3847b875 100644 --- a/content/examples/example-snippets/unmount_nfs_filesystem.cf +++ b/content/examples/example-snippets/unmount_nfs_filesystem.cf @@ -1,12 +1,9 @@ -##################################################################### # Mount NFS -##################################################################### body common control { bundlesequence => { "mounts" }; } -##################################################################### bundle agent mounts { storage: @@ -14,7 +11,6 @@ bundle agent mounts "/mnt" mount => nfs("server.example.org", "/home"); } -###################################################################### body mount nfs(server, source) { mount_type => "nfs"; diff --git a/content/examples/example-snippets/updating_from_a_central_hub.cf b/content/examples/example-snippets/updating_from_a_central_hub.cf index 918373b54..5fcce1596 100644 --- a/content/examples/example-snippets/updating_from_a_central_hub.cf +++ b/content/examples/example-snippets/updating_from_a_central_hub.cf @@ -19,7 +19,6 @@ bundle agent update depth_search => recurse("inf"); } -####################################################### body server control { allowconnects => { "127.0.0.1", "10.20.30.0/24" }; @@ -27,7 +26,6 @@ body server control trustkeysfrom => { "127.0.0.1", "10.20.30.0/24" }; } -####################################################### bundle server my_access_rules() { access: diff --git a/content/examples/example-snippets/variation_in_hosts.cf b/content/examples/example-snippets/variation_in_hosts.cf index f2d90ae39..a0e386167 100644 --- a/content/examples/example-snippets/variation_in_hosts.cf +++ b/content/examples/example-snippets/variation_in_hosts.cf @@ -3,7 +3,6 @@ body common control bundlesequence => { "central" }; } -############################################ bundle agent central { classes: @@ -34,9 +33,7 @@ bundle agent central # Add more promises below ... } -######################################################### # Server config -######################################################### body server control { allowconnects => { "127.0.0.1", "::1", "10.20.30.0/24" }; @@ -45,7 +42,6 @@ body server control # allowusers } -######################################################### bundle server my_access_rules() { access: diff --git a/content/examples/example-snippets/warn_if_matching_line_in_file.cf b/content/examples/example-snippets/warn_if_matching_line_in_file.cf index 29e6466f2..f67c7e3bf 100644 --- a/content/examples/example-snippets/warn_if_matching_line_in_file.cf +++ b/content/examples/example-snippets/warn_if_matching_line_in_file.cf @@ -1,14 +1,9 @@ -######################################################## -# # Warn if line matched -# -######################################################## body common control { bundlesequence => { "testbundle" }; } -######################################################## bundle agent testbundle { files: @@ -17,14 +12,12 @@ bundle agent testbundle action => WarnOnly; } -######################################################## bundle edit_line delete_lines_matching(regex) { delete_lines: "$(regex)" action => WarnOnly; } -######################################################## body action WarnOnly { action_policy => "warn"; diff --git a/content/examples/example-snippets/web_server_modules.cf b/content/examples/example-snippets/web_server_modules.cf index e865ef9d1..ccd781338 100644 --- a/content/examples/example-snippets/web_server_modules.cf +++ b/content/examples/example-snippets/web_server_modules.cf @@ -1,15 +1,10 @@ -####################################################### -# # Apache 2 reconfig - modelled on SuSE -# -####################################################### body common control { inputs => { "$(sys.libdir)/stdlib.cf" }; bundlesequence => { apache }; } -####################################################### bundle agent apache { files: @@ -17,9 +12,7 @@ bundle agent apache "/etc/sysconfig/apache2" edit_line => fixapache; } -####################################################### # For the library -####################################################### bundle edit_line fixapache { vars: diff --git a/content/resources/additional-topics/STIGs.cf b/content/resources/additional-topics/STIGs.cf index 3f77bcdce..32c8f6419 100644 --- a/content/resources/additional-topics/STIGs.cf +++ b/content/resources/additional-topics/STIGs.cf @@ -1,5 +1,3 @@ -################################################################################ -# # _ _ _ _ # / \ / \ / \ / \ # ( S )( T )( I )( G ) @@ -17,8 +15,6 @@ # the permission of the CFEngine company. # # $Id:$ -# -################################################################################ body common control { bundlesequence => { "stigs" }; From 1c4177967ba58772fdac989c365c8ff24e31b608 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Thu, 21 May 2026 00:34:00 +0200 Subject: [PATCH 04/10] Made autolinking fail loudly so broken links are exposed Co-authored-by: Claude Opus 4.7 (1M context) Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit 5576f74c3a35cc455a30629fa53ac31a649866c0) --- .../_scripts/cfdoc_references_resolver.py | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/generator/_scripts/cfdoc_references_resolver.py b/generator/_scripts/cfdoc_references_resolver.py index 4f6071936..64a36810d 100644 --- a/generator/_scripts/cfdoc_references_resolver.py +++ b/generator/_scripts/cfdoc_references_resolver.py @@ -35,8 +35,12 @@ def load_references(references_file): return references -def process(file_path, references): - """Process a markdown file and replace reference links with direct links.""" +def process(file_path, references, missing): + """Process a markdown file and replace reference links with direct links. + + Any reference that cannot be resolved is appended to `missing` as a + (file_path, ref) tuple so the caller can fail the build. + """ with open(file_path, "r", encoding="utf-8") as f: content = f.read() @@ -59,9 +63,7 @@ def replace_link(match): else: return f"[{text}]({url})" else: - sys.stderr.write( - f"References {ref} is not found in the _references.md. File: {file_path}\n" - ) + missing.append((file_path, ref)) return match.group(0) new_content = re.sub(pattern, replace_link, content) @@ -81,9 +83,7 @@ def replace_function_link(match): else: return f"[{text}]({url})" else: - sys.stderr.write( - f"References {ref} is not found in the _references.md. File: {file_path}\n" - ) + missing.append((file_path, f"{ref}()")) return match.group(0) new_content = re.sub(functions_pattern, replace_function_link, new_content) @@ -93,9 +93,27 @@ def replace_function_link(match): def run(config): - """Replaces [text][reference] with markdown links retrieved from _references.md""" + """Replaces [text][reference] with markdown links retrieved from _references.md. + + Exits non-zero if any reference cannot be resolved, so broken autolinks + fail the build loudly instead of silently shipping unresolved markdown. + """ markdown_files = config["markdown_files"] references = load_references("documentation/generator/_references.md") + missing = [] for file in markdown_files: - process(file, references) + process(file, references, missing) + + if missing: + sys.stderr.write( + "ERROR: %d unresolved reference link(s) found in _references.md:\n" + % len(missing) + ) + for file_path, ref in missing: + sys.stderr.write(f" [{ref}] in {file_path}\n") + sys.stderr.write( + "Add the missing entries to documentation/generator/_references.md " + "or fix the links in the listed files.\n" + ) + sys.exit(1) From 9ac161f8df6cafeedc53146df28316ce82837cf8 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Thu, 21 May 2026 01:08:49 +0200 Subject: [PATCH 05/10] Made a script to build docs locally Co-authored-by: Claude Opus 4.7 (1M context) Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit feffc4e07acf7e776493ad9e9ea860c42bb90a85) --- .gitignore | 3 ++ build-locally.sh | 131 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100755 build-locally.sh diff --git a/.gitignore b/.gitignore index 4e585782d..17db7b7d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Build artifacts cfdoc_log.markdown +/tmp/ +/output/ + # emacs *~ diff --git a/build-locally.sh b/build-locally.sh new file mode 100755 index 000000000..6a6ee17cf --- /dev/null +++ b/build-locally.sh @@ -0,0 +1,131 @@ +#!/usr/bin/env bash +# +# Build the CFEngine documentation locally in a Docker container. +# +# Self-contained: clones the sibling repos that the build expects +# (core, nova, enterprise, masterfiles, nt-docs) into ./tmp/ and runs +# the existing Docker-based pipeline against them, without requiring +# anything outside this directory. +# +# Override via env vars if needed: +# BRANCH branch name to build for (default: master) +# PACKAGE_JOB cf-remote or a buildcache job (default: cf-remote) +# PACKAGE_UPLOAD_DIRECTORY (default: n/a — unused with cf-remote) +# PACKAGE_BUILD (default: n/a — unused with cf-remote) +# LTS_VERSION (default: empty) +# DOCKER docker binary to use (default: docker) +# IMAGE_NAME tag for the build image (default: cfengine-docs-hugo) +# SKIP_PUBLISH=1 skip the _publish.sh step (just build) + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$SCRIPT_DIR" + +TMP_DIR="$SCRIPT_DIR/tmp" +CACHE_DIR="$TMP_DIR/cache" # persistent clones with .git +WORK_DIR="$TMP_DIR/work" # clean working copies (.git stripped) — what we mount +DOC_WORK="$WORK_DIR/documentation" +mkdir -p "$CACHE_DIR" "$WORK_DIR" + +BRANCH="${BRANCH:-master}" +PACKAGE_JOB="${PACKAGE_JOB:-cf-remote}" +PACKAGE_UPLOAD_DIRECTORY="${PACKAGE_UPLOAD_DIRECTORY:-n/a}" +PACKAGE_BUILD="${PACKAGE_BUILD:-n/a}" +LTS_VERSION="${LTS_VERSION:-}" +DOCKER="${DOCKER:-docker}" +IMAGE_NAME="${IMAGE_NAME:-cfengine-docs-hugo}" + +# repo_name url default_branch +REPOS=( + "core git@github.com:cfengine/core.git master" + "nova git@github.com:cfengine/nova.git master" + "enterprise git@github.com:cfengine/enterprise.git master" + "masterfiles git@github.com:cfengine/masterfiles.git master" + "nt-docs git@github.com:northerntechhq/nt-docs.git main" +) + +# 1. Clone (or update) the sibling repos under tmp/cache/, then export a +# clean working copy (no .git) to tmp/work/. We mount the .git-free +# copy because the container does `chmod -R` over each repo, and on +# macOS Docker bind mounts can't chmod git pack files written by the +# host user. +echo "==> Preparing sibling repos under $TMP_DIR" +for entry in "${REPOS[@]}"; do + # shellcheck disable=SC2086 + set -- $entry + name="$1"; url="$2"; default_branch="$3" + cache="$CACHE_DIR/$name" + work="$WORK_DIR/$name" + + if [ -d "$cache/.git" ]; then + echo " - $name: fetching latest" + git -C "$cache" fetch --quiet --tags origin + else + echo " - $name: cloning $url" + git clone --quiet "$url" "$cache" + fi + + if git -C "$cache" rev-parse --verify --quiet "origin/$BRANCH" >/dev/null; then + git -C "$cache" checkout --quiet -B "$BRANCH" "origin/$BRANCH" + else + echo " branch '$BRANCH' not found in $name; using '$default_branch'" + git -C "$cache" checkout --quiet -B "$default_branch" "origin/$default_branch" + fi + + # Export a clean snapshot for the container. Using `git archive` so + # we get exactly what's tracked, without .git or untracked junk. + rm -rf "$work" + mkdir -p "$work" + git -C "$cache" archive --format=tar HEAD | tar -x -C "$work" +done + +# 1b. Sync the documentation source itself into tmp/work/documentation. +# The build mutates files in place (sed on config.toml, cfdoc_preprocess.py +# rewriting markdown, etc.), so we must NOT bind-mount the user's checkout +# directly. Use rsync with --delete to keep the copy in sync (including +# uncommitted/untracked changes) without dragging tmp/ or .git into it. +echo "==> Syncing documentation source to $DOC_WORK" +mkdir -p "$DOC_WORK" +rsync -a --delete \ + --exclude='/tmp/' \ + --exclude='/.git/' \ + "$SCRIPT_DIR/" "$DOC_WORK/" + +# 2. Build the docker image (only if it's not already built). +if ! "$DOCKER" image inspect "$IMAGE_NAME" >/dev/null 2>&1; then + echo "==> Building docker image $IMAGE_NAME" + "$DOCKER" build --tag "$IMAGE_NAME" "$SCRIPT_DIR/generator/build" +else + echo "==> Reusing docker image $IMAGE_NAME (delete it to rebuild)" +fi + +# 3. Run the build inside the container. +# main.sh expects /nt/{documentation,core,nova,enterprise,masterfiles,nt-docs}. +# We bind-mount this checkout as /nt/documentation and each tmp/ as +# its sibling, so nothing outside this directory is touched. +echo "==> Running documentation build in container" +RUN_FLAGS=( + --rm + -v "$DOC_WORK:/nt/documentation" +) +for entry in "${REPOS[@]}"; do + # shellcheck disable=SC2086 + set -- $entry + RUN_FLAGS+=(-v "$WORK_DIR/$1:/nt/$1") +done + +"$DOCKER" run "${RUN_FLAGS[@]}" "$IMAGE_NAME" \ + bash -x documentation/generator/build/main.sh \ + "$BRANCH" "$PACKAGE_JOB" "$PACKAGE_UPLOAD_DIRECTORY" \ + "$PACKAGE_BUILD" "$LTS_VERSION" + +# 4. Optionally package the result (mirrors the Jenkins pipeline). +if [ -z "${SKIP_PUBLISH:-}" ]; then + echo "==> Packaging output" + "$DOCKER" run "${RUN_FLAGS[@]}" "$IMAGE_NAME" \ + bash -x documentation/generator/_scripts/_publish.sh "$BRANCH" +fi + +echo "==> Done. Generated site is in: $DOC_WORK/generator/_site" +echo " Tarballs (if packaged) are in: $DOC_WORK/output/" From fd856ff41db0c988cddebdd12b2b9c1e4bc5fdfd Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Thu, 21 May 2026 01:21:22 +0200 Subject: [PATCH 06/10] Fixed issue where autolinking tries to put autolinks in policy Co-authored-by: Claude Opus 4.7 (1M context) Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit 2d317326a2706cb72555f44081138ab83f9b66dd) --- generator/_scripts/cfdoc_linkresolver.py | 21 ++++++--- .../_scripts/cfdoc_references_resolver.py | 44 +++++++++++++++---- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/generator/_scripts/cfdoc_linkresolver.py b/generator/_scripts/cfdoc_linkresolver.py index bf90c8f64..5b7785a87 100644 --- a/generator/_scripts/cfdoc_linkresolver.py +++ b/generator/_scripts/cfdoc_linkresolver.py @@ -237,12 +237,21 @@ def applyLinkMap(file_name, config): for markdown_line in markdown_lines: config["context_current_line_number"] += 1 # we ignore everything in code blocks - if previous_empty or in_pre: - if markdown_line.lstrip()[:3] == "```": - in_pre = not in_pre - if markdown_line[:4] == " ": - new_lines.append(markdown_line) - continue + # triple-backtick fences must be detected on every line, not only after + # a blank line, otherwise content inside the block gets autolinked + if markdown_line.lstrip()[:3] == "```": + in_pre = not in_pre + new_lines.append(markdown_line) + previous_empty = False + continue + if in_pre: + new_lines.append(markdown_line) + previous_empty = markdown_line.lstrip() == "" + continue + if previous_empty and markdown_line[:4] == " ": + new_lines.append(markdown_line) + previous_empty = False + continue # don't link to the current section if markdown_line.find("title:") == 0: diff --git a/generator/_scripts/cfdoc_references_resolver.py b/generator/_scripts/cfdoc_references_resolver.py index 64a36810d..f511a5aaa 100644 --- a/generator/_scripts/cfdoc_references_resolver.py +++ b/generator/_scripts/cfdoc_references_resolver.py @@ -40,15 +40,34 @@ def process(file_path, references, missing): Any reference that cannot be resolved is appended to `missing` as a (file_path, ref) tuple so the caller can fail the build. + + Code content is skipped so that things that look like reference links but + aren't (CFEngine array notation `a[b][c]`, sample output `[1][0]`, etc.) + don't get treated as broken `[text][ref]` links: + * Triple-backtick fenced code blocks — common when snippets are pulled + in from the core repo via macros. + * Inline single-backtick code spans on a single line. + + Function-name autolinking (``foo()``) is the inverse: it deliberately + targets backtick-quoted text, so it runs on every non-fenced line. """ with open(file_path, "r", encoding="utf-8") as f: - content = f.read() + lines = f.readlines() # Pattern to match reference links: [`text`][reference] - pattern = r"\[(.*?)\]\[(.*?)\]" + pattern = re.compile(r"\[(.*?)\]\[(.*?)\]") + # finds functions except ones already processed inside [] + functions_pattern = re.compile(r"(? Date: Wed, 17 Jun 2026 13:50:14 +0200 Subject: [PATCH 07/10] Added _no_links.md to explicitly skip autolinking for some exceptions Co-authored-by: Claude Opus 4.8 Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit bd0de935bb35509f72b34bd9e0d61c1bfc64f3fe) --- generator/_no_links.md | 12 +++++ .../_scripts/cfdoc_references_resolver.py | 44 ++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 generator/_no_links.md diff --git a/generator/_no_links.md b/generator/_no_links.md new file mode 100644 index 000000000..5058beb58 --- /dev/null +++ b/generator/_no_links.md @@ -0,0 +1,12 @@ + + +validate_promise() +evaluate_promise() diff --git a/generator/_scripts/cfdoc_references_resolver.py b/generator/_scripts/cfdoc_references_resolver.py index f511a5aaa..7d125dc47 100644 --- a/generator/_scripts/cfdoc_references_resolver.py +++ b/generator/_scripts/cfdoc_references_resolver.py @@ -35,7 +35,43 @@ def load_references(references_file): return references -def process(file_path, references, missing): +def load_no_links(no_links_file): + """Parse the _no_links.md file and return a set of function names that + should NOT be autolinked. + + Each non-empty, non-comment line is a name like ``foo()`` or ``foo``; the + trailing ``()`` is optional. HTML comment blocks (````, possibly + spanning multiple lines) are ignored. Names are stored lowercased for + case-insensitive matching against autolink candidates. + """ + no_links = set() + + path = os.path.join(os.environ.get("WRKDIR"), no_links_file) + if not os.path.exists(path): + sys.stderr.write( + f"Warning: No-links file {path} not found. All function names will be autolinked.\n" + ) + return no_links + + try: + with open(path, "r", encoding="utf-8") as file: + content = file.read() + except Exception as e: + sys.stderr.write(f"Error reading no-links file {path}: {str(e)}\n") + return no_links + + # Drop HTML comment blocks (including multi-line ones) before parsing names. + content = re.sub(r"", "", content, flags=re.DOTALL) + for line in content.splitlines(): + line = line.strip() + if not line: + continue + no_links.add(line.removesuffix("()").lower()) + + return no_links + + +def process(file_path, references, no_links, missing): """Process a markdown file and replace reference links with direct links. Any reference that cannot be resolved is appended to `missing` as a @@ -89,6 +125,9 @@ def replace_function_link(match): ref = match.group(1) text = f"{ref}()" ref_lower = ref.lower() + if ref_lower in no_links: + # Explicitly opted out of autolinking; leave as plain text. + return match.group(0) if ref_lower in references: url, title = references[ref_lower] if title: @@ -126,10 +165,11 @@ def run(config): """ markdown_files = config["markdown_files"] references = load_references("documentation/generator/_references.md") + no_links = load_no_links("documentation/generator/_no_links.md") missing = [] for file in markdown_files: - process(file, references, missing) + process(file, references, no_links, missing) if missing: sys.stderr.write( From 671e249667dce370221d3abcf6baac809e4b0742 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Wed, 17 Jun 2026 16:36:25 +0200 Subject: [PATCH 08/10] Fixed issue with cfdoc_log.markdown being included in the build This file was growing with more and more content which caused errors during build, like broken links. Co-authored-by: Claude Opus 4.8 Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit 797458b8e9dfcb39056c2dae83122861c96128ef) --- build-locally.sh | 10 ++++++++++ generator/_scripts/cfdoc_references_resolver.py | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/build-locally.sh b/build-locally.sh index 6a6ee17cf..19c24a2d6 100755 --- a/build-locally.sh +++ b/build-locally.sh @@ -85,12 +85,22 @@ done # rewriting markdown, etc.), so we must NOT bind-mount the user's checkout # directly. Use rsync with --delete to keep the copy in sync (including # uncommitted/untracked changes) without dragging tmp/ or .git into it. +# cfdoc_log.markdown is a build artifact written into content/ by cfdoc_qa.py +# (it's gitignored). If a previous run left it behind, the link checker +# re-parses its log entries — which themselves contain literal +# [foo#foo][foo#foo] markdown — and reports hundreds of bogus "unresolved +# reference" errors. We must clear it from both sides: --exclude keeps the +# host's copy from being synced in, and the explicit rm removes any copy a +# previous in-container build wrote into the work tree (rsync --delete will +# NOT remove an --exclude'd path, so the exclude alone is not enough). echo "==> Syncing documentation source to $DOC_WORK" mkdir -p "$DOC_WORK" rsync -a --delete \ --exclude='/tmp/' \ --exclude='/.git/' \ + --exclude='/content/cfdoc_log.markdown' \ "$SCRIPT_DIR/" "$DOC_WORK/" +rm -f "$DOC_WORK/content/cfdoc_log.markdown" # 2. Build the docker image (only if it's not already built). if ! "$DOCKER" image inspect "$IMAGE_NAME" >/dev/null 2>&1; then diff --git a/generator/_scripts/cfdoc_references_resolver.py b/generator/_scripts/cfdoc_references_resolver.py index 7d125dc47..2531c5b76 100644 --- a/generator/_scripts/cfdoc_references_resolver.py +++ b/generator/_scripts/cfdoc_references_resolver.py @@ -169,6 +169,12 @@ def run(config): missing = [] for file in markdown_files: + # cfdoc_log.markdown is the QA log written by cfdoc_qa.py, not real + # documentation. Its entries quote link warnings using literal + # [foo#foo][foo#foo] markdown, so linting it produces hundreds of bogus + # "unresolved reference" errors. Never treat it as a source file. + if os.path.basename(file) == "cfdoc_log.markdown": + continue process(file, references, no_links, missing) if missing: From 39628b5998c3d43051c53ba38598f035b57777f2 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Wed, 17 Jun 2026 21:08:53 +0200 Subject: [PATCH 09/10] Fixed build errors Co-authored-by: Claude Opus 4.8 Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit c07580c28ea733444216d9eeb52aa5c9fa7df30b) --- .../adjusting-schedules.markdown | 4 ++-- generator/_references.md | 1 + generator/_scripts/cfdoc_macros.py | 22 +++++++++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/content/web-ui/hub_administration/adjusting-schedules.markdown b/content/web-ui/hub_administration/adjusting-schedules.markdown index 4664ac8a5..752dee5b1 100644 --- a/content/web-ui/hub_administration/adjusting-schedules.markdown +++ b/content/web-ui/hub_administration/adjusting-schedules.markdown @@ -8,8 +8,8 @@ aliases: ## Set cf-execd agent execution schedule By default `cf-execd` is configured to run `cf-agent` every 5 minutes. This can -be adjusted by tuning the [schedule][cf-execd#schedule] in `body executor -control`. In the [Masterfiles Policy Framework][Masterfiles Policy Framework] body +be adjusted by tuning the [schedule][cf-execd#schedule] in +`body executor control`. In the [Masterfiles Policy Framework][Masterfiles Policy Framework] body executor control can be found in `controls/cf_execd.cf` ## Set cf-hub hub_schedule diff --git a/generator/_references.md b/generator/_references.md index 77f8abddd..bca1c63ce 100644 --- a/generator/_references.md +++ b/generator/_references.md @@ -39,6 +39,7 @@ [sys.uqhost]: reference-special-variables-sys.html#sys-uqhost [sys.policy_hub]: reference-special-variables-sys.html#sys-policy_hub [seed_cp]: reference-masterfiles-policy-framework-lib-files.html#seed_cp +[Masterfiles Policy Framework]: reference-masterfiles-policy-framework.html [Append to inputs used by main policy]: reference-masterfiles-policy-framework.html#append-to-inputs-used-by-main-policy [mpf_extra_autorun_inputs]: reference-masterfiles-policy-framework.html#additional-automatically-loaded-inputs [Append to inputs used by update policy]: reference-masterfiles-policy-framework.html#append-to-inputs-used-by-update-policy diff --git a/generator/_scripts/cfdoc_macros.py b/generator/_scripts/cfdoc_macros.py index 8fc407a2d..cc7012239 100644 --- a/generator/_scripts/cfdoc_macros.py +++ b/generator/_scripts/cfdoc_macros.py @@ -620,11 +620,25 @@ def prune_include_lines(markdown_lines, filename): # unless included example starts with an explicit code block, start a (CFEngine-brushed) block if markdown_lines[0].find("```") != 0: markdown_lines.insert(0, "\n```%s\n" % brush) - # if example ended with documentation, prune trailing code, else terminate block - if markdown_lines[-1] != ("\n```%s\n" % brush): - markdown_lines.append("```\n") - else: + if markdown_lines[-1] == ("\n```%s\n" % brush): + # snippet ended by opening a fresh (empty) code block; drop it del markdown_lines[-1] + else: + # Close the block only if the snippet actually ends *inside* one. + # An example that ends with documentation (#@ ...) has already + # closed its last code block, so appending another ``` would leave + # an unmatched fence that swallows all the content following the + # include (e.g. hiding real reference links from the resolvers). + in_code = False + for ml in markdown_lines: + stripped = ml.lstrip() + if stripped.startswith("```") and "```" not in stripped[3:]: + if not in_code: + in_code = True + elif stripped.strip().strip("`") == "": + in_code = False + if in_code: + markdown_lines.append("```\n") return markdown_lines From fe5ad4632c3aee9dee3759770a60ca9c52723dc1 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Wed, 17 Jun 2026 13:53:00 +0200 Subject: [PATCH 10/10] Fixed link for custom promise types Co-authored-by: Claude Opus 4.8 Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit 01e4f59e2e1b64d93d4a37cec8291f6e7440f65f) --- .../promise-type-module-development.markdown | 2 +- .../general-installation/_index.markdown | 2 +- .../local-virtual-machine.markdown | 2 +- content/overview/_index.markdown | 2 +- .../reference/promise-types/services.markdown | 2 +- .../resources/faq/bootstrap-failed.markdown | 4 +- .../faq/integrate-custom-policy.markdown | 4 +- ...y-are-files-not-being-distributed.markdown | 2 +- generator/_no_links.md | 3 ++ generator/_scripts/cfdoc_linkresolver.py | 18 +++++++-- .../_scripts/cfdoc_references_resolver.py | 37 ++++++++++++++++--- 11 files changed, 58 insertions(+), 20 deletions(-) diff --git a/content/examples/tutorials/promise-type-module-development.markdown b/content/examples/tutorials/promise-type-module-development.markdown index 9b6cb5558..eb92b007f 100644 --- a/content/examples/tutorials/promise-type-module-development.markdown +++ b/content/examples/tutorials/promise-type-module-development.markdown @@ -10,7 +10,7 @@ aliases: Promise type modules are easy to write. In this tutorial, we will focus on implementing a new promise type in Python, with the provided CFEngine library, since this is the easiest and recommended way. -If you are interested in how modules are implemented, or how you could do it in another programming language, see the [complete documentation][custom]. +If you are interested in how modules are implemented, or how you could do it in another programming language, see the [complete documentation][promise-type-custom]. In short, you need to implement 2 functions: `validate_promise()` and `evaluate_promise()`. _Validation_ should check that the correct attributes are used, and any other constraints you may want to enforce, to determine whether a promise is valid or invalid. diff --git a/content/getting-started/01-installing-cfengine/general-installation/_index.markdown b/content/getting-started/01-installing-cfengine/general-installation/_index.markdown index 9a56fa7c3..26db4e8ce 100644 --- a/content/getting-started/01-installing-cfengine/general-installation/_index.markdown +++ b/content/getting-started/01-installing-cfengine/general-installation/_index.markdown @@ -119,7 +119,7 @@ Edit `/etc/hosts` and add an entry for the IP address and hostname of the server ### CFEngine Enterprise post-installation setup -See: [What steps should I take after installing CFEngine Enterprise?][FAQ#What steps should I take after installing CFEngine Enterprise] +See: [What steps should I take after installing CFEngine Enterprise?][Enterprise reporting database#What steps should I take after installing CFEngine Enterprise?] ## More detailed installation guides diff --git a/content/getting-started/01-installing-cfengine/local-virtual-machine.markdown b/content/getting-started/01-installing-cfengine/local-virtual-machine.markdown index 98f5938eb..ee5256a50 100644 --- a/content/getting-started/01-installing-cfengine/local-virtual-machine.markdown +++ b/content/getting-started/01-installing-cfengine/local-virtual-machine.markdown @@ -121,4 +121,4 @@ vagrant destroy hub Now that you have a Linux VM ready, go back to the main tutorial to install CFEngine: -[Installation][Installation] +[Installation][Installing CFEngine] diff --git a/content/overview/_index.markdown b/content/overview/_index.markdown index 55f97a381..38341195c 100644 --- a/content/overview/_index.markdown +++ b/content/overview/_index.markdown @@ -6,7 +6,7 @@ aliases: - "/overview.html" --- -CFEngine is a distributed system for managing and monitoring computers across an IT network. Machines on the network that have CFEngine installed, and have registered themselves with a policy server (see [Installation][Installation]), will each be running a set of CFEngine component applications that manage and interpret a textual representation of your desired state for the system, referred to as policy. Policy files themselves contain sets of instructions to ensure machines on the network are in full compliance with a defined state. At the atomic level are sets, or _bundles_, of what are known in the CFEngine world as [Promises][Promises]. _Promises_ are at the heart of Promise Theory, which is in turn what CFEngine is all about. +CFEngine is a distributed system for managing and monitoring computers across an IT network. Machines on the network that have CFEngine installed, and have registered themselves with a policy server (see [Installation][Installing CFEngine]), will each be running a set of CFEngine component applications that manage and interpret a textual representation of your desired state for the system, referred to as policy. Policy files themselves contain sets of instructions to ensure machines on the network are in full compliance with a defined state. At the atomic level are sets, or _bundles_, of what are known in the CFEngine world as [Promises][Promises]. _Promises_ are at the heart of Promise Theory, which is in turn what CFEngine is all about. ## Policy language and compliance diff --git a/content/reference/promise-types/services.markdown b/content/reference/promise-types/services.markdown index 7ed5dd152..79b4598b1 100644 --- a/content/reference/promise-types/services.markdown +++ b/content/reference/promise-types/services.markdown @@ -249,7 +249,7 @@ bundle agent my_custom_service_method_deb( service_identifier, desired_service_s } ``` -**See also:** [generic standard_services][Services Bodies and Bundles#standard_services] +**See also:** [generic standard_services][lib/services.cf] **History:** diff --git a/content/resources/faq/bootstrap-failed.markdown b/content/resources/faq/bootstrap-failed.markdown index abb32d05a..eefa75aba 100644 --- a/content/resources/faq/bootstrap-failed.markdown +++ b/content/resources/faq/bootstrap-failed.markdown @@ -136,7 +136,7 @@ In order for a host to communicate it must be within an IP range that is allowed - `def.acl` in the Masterfiles Policy Framework is included in this list by default. -See also: [`def.acl`][Masterfiles Policy Framework#acl], [`def.trustkeysfrom`][Masterfiles Policy Framework#trustkeysfrom] +See also: [`def.acl`][Masterfiles Policy Framework#acl], [`def.trustkeysfrom`][Masterfiles Policy Framework#Automatic bootstrap - Trusting keys from new hosts with trustkeysfrom] ### `trustkeysfrom` in `body server control` @@ -149,4 +149,4 @@ This defines networks from which a host will automatically trust hosts. If you d - `verbose: 192.168.56.4> Trying old style '/var/cfengine/ppkeys/root-192.168.56.4.pub'` - `verbose: 192.168.56.4> Received key 'SHA=85f8a23d6738599e03951e6930e661bcd9bb3ae12f32486c9795cc9baa7d5b4e' not found in ppkeys` -See also: [`def.acl`][Masterfiles Policy Framework#acl], [`def.trustkeysfrom`][Masterfiles Policy Framework#trustkeysfrom] +See also: [`def.acl`][Masterfiles Policy Framework#acl], [`def.trustkeysfrom`][Masterfiles Policy Framework#Automatic bootstrap - Trusting keys from new hosts with trustkeysfrom] diff --git a/content/resources/faq/integrate-custom-policy.markdown b/content/resources/faq/integrate-custom-policy.markdown index cfad1716a..e102076d5 100644 --- a/content/resources/faq/integrate-custom-policy.markdown +++ b/content/resources/faq/integrate-custom-policy.markdown @@ -22,7 +22,7 @@ The _autorun_ feature in the Masterfiles Policy Framework automatically adds policy files found in `services/autorun` to inputs and executes bundles tagged with _autorun_ as methods type promises in lexical order. -**See also:** [`services_autorun` in the Masterfiles Policy Framework][Masterfiles Policy Framework#services\_autorun] +**See also:** [`services_autorun` in the Masterfiles Policy Framework][mpf-services-autorun] ## Using augments @@ -51,7 +51,7 @@ To extend inputs in the update policy define `update_inputs`. } ``` -**See also:** [Augments][Augments], [Extend inputs for update policy in the Masterfiles Policy Framework][Masterfiles Policy Framework#Append to inputs used by update policy] +**See also:** [Augments][Augments], [Extend inputs for update policy in the Masterfiles Policy Framework][Append to inputs used by update policy] ## Using body file control diff --git a/content/resources/faq/why-are-files-not-being-distributed.markdown b/content/resources/faq/why-are-files-not-being-distributed.markdown index 6aca0d9f6..bea543f0b 100644 --- a/content/resources/faq/why-are-files-not-being-distributed.markdown +++ b/content/resources/faq/why-are-files-not-being-distributed.markdown @@ -13,4 +13,4 @@ However not all files are considered for update in the default update policy. The default update policy in the MPF only copies files matching a list of -regular expressions defined in [update_def.input_name_patterns][Masterfiles Policy Framework#files considered for copy during policy updates] +regular expressions defined in [update_def.input_name_patterns][Masterfiles Policy Framework#Extend files considered for copy during policy updates] diff --git a/generator/_no_links.md b/generator/_no_links.md index 5058beb58..47dcb4f57 100644 --- a/generator/_no_links.md +++ b/generator/_no_links.md @@ -10,3 +10,6 @@ validate_promise() evaluate_promise() +PolicyResolve() +BodyToJson() +BundleToJson() diff --git a/generator/_scripts/cfdoc_linkresolver.py b/generator/_scripts/cfdoc_linkresolver.py index 5b7785a87..5b8c2e45e 100644 --- a/generator/_scripts/cfdoc_linkresolver.py +++ b/generator/_scripts/cfdoc_linkresolver.py @@ -237,15 +237,25 @@ def applyLinkMap(file_name, config): for markdown_line in markdown_lines: config["context_current_line_number"] += 1 # we ignore everything in code blocks - # triple-backtick fences must be detected on every line, not only after - # a blank line, otherwise content inside the block gets autolinked - if markdown_line.lstrip()[:3] == "```": - in_pre = not in_pre + # Track fenced code blocks the way CommonMark/Hugo do, so we don't + # autolink inside code and don't lose state on macro-injected examples: + # * a line is a fence only if it starts with ``` and has no further + # ``` on the same line (inline "```x```" is not a fence); + # * an open block closes only on a *bare* ``` (no info string), so a + # "```cf3" line appearing inside an open block counts as content. + # A naive toggle miscounts inner fences and flips the in/out-of-code + # state for the rest of the file. + stripped = markdown_line.lstrip() + is_fence = stripped.startswith("```") and "```" not in stripped[3:] + if is_fence and not in_pre: + in_pre = True new_lines.append(markdown_line) previous_empty = False continue if in_pre: new_lines.append(markdown_line) + if is_fence and stripped.strip().strip("`") == "": + in_pre = False previous_empty = markdown_line.lstrip() == "" continue if previous_empty and markdown_line[:4] == " ": diff --git a/generator/_scripts/cfdoc_references_resolver.py b/generator/_scripts/cfdoc_references_resolver.py index 2531c5b76..4d44a5cb1 100644 --- a/generator/_scripts/cfdoc_references_resolver.py +++ b/generator/_scripts/cfdoc_references_resolver.py @@ -91,10 +91,17 @@ def process(file_path, references, no_links, missing): with open(file_path, "r", encoding="utf-8") as f: lines = f.readlines() - # Pattern to match reference links: [`text`][reference] - pattern = re.compile(r"\[(.*?)\]\[(.*?)\]") - # finds functions except ones already processed inside [] - functions_pattern = re.compile(r"(?