From e415520fead139bdc84692c24040355443b997a0 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Thu, 16 Apr 2026 01:57:38 +0200 Subject: [PATCH 1/2] Reformatted some initial files with cfengine format Signed-off-by: Ole Herman Schumacher Elgesem --- cfe_internal/CFE_cfengine.cf | 26 +++---- inventory/aix.cf | 55 ++++++--------- inventory/debian.cf | 132 ++++++++++++++++++++++------------- inventory/suse.cf | 6 +- lib/users.cf | 9 ++- 5 files changed, 126 insertions(+), 102 deletions(-) diff --git a/cfe_internal/CFE_cfengine.cf b/cfe_internal/CFE_cfengine.cf index 080f2288ae..ca2f0b2a28 100644 --- a/cfe_internal/CFE_cfengine.cf +++ b/cfe_internal/CFE_cfengine.cf @@ -18,22 +18,21 @@ bundle common cfe_internal_management_file_control # @brief Define policy input dependancies { vars: - - "inputs" slist => { }; + "inputs" slist => {}; cfengine_recommendations_enabled:: "input[cfengine_recommendations]" string => "$(this.promise_dirname)/recommendations.cf"; any:: - "inputs" slist => getvalues( input ); + "inputs" slist => getvalues(input); } body file control # @brief Include policy input dependancies { - cfengine_recommendations_enabled:: - inputs => { @(cfe_internal_management_file_control.inputs) }; + cfengine_recommendations_enabled:: + inputs => { @(cfe_internal_management_file_control.inputs) }; } bundle agent cfe_internal_management @@ -59,20 +58,15 @@ bundle agent cfe_internal_management "bundles" slist => getindices(policy); "recommendation_bundles" - slist => sort( bundlesmatching( ".*", "cfengine_recommends" ), lex); + slist => sort(bundlesmatching(".*", "cfengine_recommends"), lex); methods: + # CFEngine internals + "CFEngine_Internals" usebundle => "$(bundles)"; - # - # CFEngine internals - # - - "CFEngine_Internals" - usebundle => "$(bundles)"; - - "CFEngine Recommendations" - usebundle => $(recommendation_bundles), - if => isvariable( recommendation_bundles ); + "CFEngine Recommendations" + usebundle => $(recommendation_bundles), + if => isvariable(recommendation_bundles); reports: DEBUG|DEBUG_cfe_internal_management:: diff --git a/inventory/aix.cf b/inventory/aix.cf index 30353dc4d4..6076f3df4c 100644 --- a/inventory/aix.cf +++ b/inventory/aix.cf @@ -4,8 +4,7 @@ bundle agent inventory_aix # This agent bundle is for AIX inventory work. { methods: - "oslevel" - usebundle => inventory_aix_oslevel; + "oslevel" usebundle => inventory_aix_oslevel; } bundle agent inventory_aix_oslevel @@ -14,19 +13,17 @@ bundle agent inventory_aix_oslevel # for up to 1 day before re-discovering. { vars: - "oslevel" - string => ifelse( isvariable( "paths.oslevel" ), $(paths.oslevel), - "/usr/bin/oslevel" ); + string => ifelse( + isvariable("paths.oslevel"), $(paths.oslevel), "/usr/bin/oslevel" + ); commands: - aix:: - "$(oslevel)" handle => "cache_aix_oslevel_s", args => "-s > $(sys.statedir)/aix-oslevel-s", - if => not( fileexists( "$(sys.statedir)/aix-oslevel-s" ) ), + if => not(fileexists("$(sys.statedir)/aix-oslevel-s")), contain => in_shell, comment => "We cache the highest service pack reached to avoid unnecessary command executions."; @@ -34,45 +31,39 @@ bundle agent inventory_aix_oslevel "$(oslevel)" handle => "cache_aix_oslevel_r", args => "-r > $(sys.statedir)/aix-oslevel-r", - if => not( fileexists( "$(sys.statedir)/aix-oslevel-r" ) ), + if => not(fileexists("$(sys.statedir)/aix-oslevel-r")), contain => in_shell, comment => "We cache the highest technology level reached to avoid unnecessary command executions."; files: - aix:: - "$(sys.statedir)/aix-oslevel-r" handle => "cache_expire_aix_oslevel_r", delete => tidy, - file_select => days_old( 1 ), + file_select => days_old(1), comment => "We regularly clear the cache to avoid stale data"; "$(sys.statedir)/aix-oslevel-s" handle => "cache_expire_aix_oslevel_s", delete => tidy, - file_select => days_old( 1 ), + file_select => days_old(1), comment => "We regularly clear the cache to avoid stale data"; - vars: - + vars: aix:: - - "oslevel_s" - string => readfile("$(sys.statedir)/aix-oslevel-s", 1K ), - if => fileexists("$(sys.statedir)/aix-oslevel-s"), - meta => { "inventory", "attribute_name=Highest Service Pack" }; - - "oslevel_r" - string => readfile("$(sys.statedir)/aix-oslevel-r", 1K), - if => fileexists("$(sys.statedir)/aix-oslevel-r"), - meta => { "inventory", "attribute_name=Highest Technology Level" }; - - reports: - - DEBUG:: - - "Highest Service Pack: $(oslevel_s)"; - "Highest Technology Level: $(oslevel_r)"; + "oslevel_s" + string => readfile("$(sys.statedir)/aix-oslevel-s", 1K), + if => fileexists("$(sys.statedir)/aix-oslevel-s"), + meta => { "inventory", "attribute_name=Highest Service Pack" }; + + "oslevel_r" + string => readfile("$(sys.statedir)/aix-oslevel-r", 1K), + if => fileexists("$(sys.statedir)/aix-oslevel-r"), + meta => { "inventory", "attribute_name=Highest Technology Level" }; + + reports: + DEBUG:: + "Highest Service Pack: $(oslevel_s)"; + "Highest Technology Level: $(oslevel_r)"; } diff --git a/inventory/debian.cf b/inventory/debian.cf index a260dad332..a072f711f7 100644 --- a/inventory/debian.cf +++ b/inventory/debian.cf @@ -5,58 +5,90 @@ bundle common inventory_debian { vars: has_lsb_release:: - "lsb_release_info" string => readfile("/etc/lsb-release","256"), - comment => "Read more OS info" ; + "lsb_release_info" + string => readfile("/etc/lsb-release", "256"), + comment => "Read more OS info"; has_etc_linuxmint_info:: - "linuxmint_info" string => readfile("/etc/linuxmint/info","1024"), - comment => "Read Linux Mint specific info" ; + "linuxmint_info" + string => readfile("/etc/linuxmint/info", "1024"), + comment => "Read Linux Mint specific info"; "lm_info_count" - int => parsestringarray("mint_info", # array to populate - "$(linuxmint_info)", # data to parse - "\s*#[^\n]*", # comments - "=", # split - 100, # maxentries - 2048) ; # maxbytes - - "mint_release" string => "$(mint_info[RELEASE][1])" ; - "mint_codename" string => "$(mint_info[CODENAME][1])" ; + int => parsestringarray( + "mint_info", + # array to populate + "$(linuxmint_info)", + # data to parse + "\s*#[^\n]*", + # comments + "=", + # split + 100, + # maxentries + 2048 + ); + + # maxbytes + "mint_release" string => "$(mint_info[RELEASE][1])"; + "mint_codename" string => "$(mint_info[CODENAME][1])"; classes: any:: "debian_derived_evaluated" - scope => "bundle", - or => { isvariable("sys.os_release"), "has_lsb_release", "has_etc_linuxmint_info" } ; + scope => "bundle", + or => { + isvariable("sys.os_release"), + "has_lsb_release", + "has_etc_linuxmint_info", + }; "linuxmint" - expression => "has_etc_linuxmint_info", - comment => "this is a Linux Mint system, of some sort", - meta => { "inventory", "attribute_name=none" } ; + expression => "has_etc_linuxmint_info", + comment => "this is a Linux Mint system, of some sort", + meta => { "inventory", "attribute_name=none" }; has_lsb_release:: "linuxmint" - expression => regcmp("(?ms).*^DISTRIB_ID=LinuxMint$.*", "$(lsb_release_info)"), - comment => "this is a Linux Mint system, of some sort", - meta => { "inventory", "attribute_name=none" } ; + expression => regcmp( + "(?ms).*^DISTRIB_ID=LinuxMint$.*", "$(lsb_release_info)" + ), + comment => "this is a Linux Mint system, of some sort", + meta => { "inventory", "attribute_name=none" }; linuxmint:: "lmde" - expression => regcmp('.*LMDE.*', "$(sys.os_release[NAME])"), - comment => "this is a Linux Mint Debian Edition", - meta => { "inventory", "attribute_name=none", "derived-from=sys.os_release[NAME]" } ; + expression => regcmp('.*LMDE.*', "$(sys.os_release[NAME])"), + comment => "this is a Linux Mint Debian Edition", + meta => { + "inventory", + "attribute_name=none", + "derived-from=sys.os_release[NAME]", + }; linuxmint.has_lsb_release:: "lmde" - expression => regcmp('(?ms).*^DISTRIB_DESCRIPTION="LMDE.*', "$(lsb_release_info)"), - comment => "this is a Linux Mint Debian Edition", - meta => { "inventory", "attribute_name=none", "derived-from=inventory_debian.lsb_release_info" } ; + expression => regcmp( + '(?ms).*^DISTRIB_DESCRIPTION="LMDE.*', "$(lsb_release_info)" + ), + comment => "this is a Linux Mint Debian Edition", + meta => { + "inventory", + "attribute_name=none", + "derived-from=inventory_debian.lsb_release_info", + }; has_etc_linuxmint_info:: "lmde" - expression => regcmp('(?ms).*^DESCRIPTION="LMDE.*',"$(linuxmint_info)"), - comment => "this is a Linux Mint Debian Edition", - meta => { "inventory", "attribute_name=none", "derived-from=inventory_debian.linuxmint_info" } ; + expression => regcmp( + '(?ms).*^DESCRIPTION="LMDE.*', "$(linuxmint_info)" + ), + comment => "this is a Linux Mint Debian Edition", + meta => { + "inventory", + "attribute_name=none", + "derived-from=inventory_debian.linuxmint_info", + }; debian_derived_evaluated.has_etc_linuxmint_info.!lmde:: # These need to be evaluated only after debian_derived_evaluated is defined @@ -64,29 +96,35 @@ bundle common inventory_debian # Failing to do that will create meaningless classes # On non-LMDE Mint systems, this will create classes like, e.g.: # linuxmint_14, nadia, linuxmint_nadia - "linuxmint_$(mint_release)" expression => "any", - meta => { "inventory", "attribute_name=none" } ; + "linuxmint_$(mint_release)" + expression => "any", + meta => { "inventory", "attribute_name=none" }; - "$(mint_codename)" expression => "any", - meta => { "inventory", "attribute_name=none" } ; + "$(mint_codename)" + expression => "any", + meta => { "inventory", "attribute_name=none" }; - "linuxmint_$(mint_codename)" expression => "any", - meta => { "inventory", "attribute_name=none" } ; + "linuxmint_$(mint_codename)" + expression => "any", + meta => { "inventory", "attribute_name=none" }; debian_derived_evaluated:: - "debian_pure" expression => "debian.!(ubuntu|linuxmint)", - comment => "pure Debian", - meta => { "inventory", "attribute_name=none" }; + "debian_pure" + expression => "debian.!(ubuntu|linuxmint)", + comment => "pure Debian", + meta => { "inventory", "attribute_name=none" }; - "debian_derived" expression => "debian.!debian_pure", - comment => "derived from Debian", - meta => { "inventory", "attribute_name=none" }; + "debian_derived" + expression => "debian.!debian_pure", + comment => "derived from Debian", + meta => { "inventory", "attribute_name=none" }; any:: - "has_lsb_release" expression => fileexists("/etc/lsb-release"), - comment => "Check if we can get more info from /etc/lsb-release"; - - "has_etc_linuxmint_info" expression => fileexists("/etc/linuxmint/info"), - comment => "If this is a Linux Mint system, this *could* be available"; + "has_lsb_release" + expression => fileexists("/etc/lsb-release"), + comment => "Check if we can get more info from /etc/lsb-release"; + "has_etc_linuxmint_info" + expression => fileexists("/etc/linuxmint/info"), + comment => "If this is a Linux Mint system, this *could* be available"; } diff --git a/inventory/suse.cf b/inventory/suse.cf index 646279c288..c325c47666 100644 --- a/inventory/suse.cf +++ b/inventory/suse.cf @@ -4,11 +4,13 @@ bundle common inventory_suse # This common bundle is for SUSE Linux inventory work. { classes: - "suse_pure" expression => "(sles|sled).!opensuse", + "suse_pure" + expression => "(sles|sled).!opensuse", comment => "pure SUSE", meta => { "inventory", "attribute_name=none" }; - "suse_derived" expression => "opensuse.!suse_pure", + "suse_derived" + expression => "opensuse.!suse_pure", comment => "derived from SUSE", meta => { "inventory", "attribute_name=none" }; } diff --git a/lib/users.cf b/lib/users.cf index be44f92694..6709081aaf 100644 --- a/lib/users.cf +++ b/lib/users.cf @@ -1,5 +1,4 @@ # Users bodies - body password plaintext_password(text) # @brief Sets the plaintext password for the user to `text` # @param text the plain text version of the password @@ -8,8 +7,8 @@ body password plaintext_password(text) # # **See also:** `hashed_password()` { - format => "plaintext"; - data => $(text); + format => "plaintext"; + data => $(text); } body password hashed_password(hash) @@ -20,6 +19,6 @@ body password hashed_password(hash) # # **See also:** `plaintext_password()` { - format => "hash"; - data => $(hash); + format => "hash"; + data => $(hash); } From e5fdacb44c0ae9c6259a481698682886f08def3b Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Fri, 17 Apr 2026 13:52:15 +0200 Subject: [PATCH 2/2] inventory/debian.cf: Manually adjusted 1 comment location Signed-off-by: Ole Herman Schumacher Elgesem --- inventory/debian.cf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inventory/debian.cf b/inventory/debian.cf index a072f711f7..55861e16c9 100644 --- a/inventory/debian.cf +++ b/inventory/debian.cf @@ -27,9 +27,9 @@ bundle common inventory_debian 100, # maxentries 2048 + # maxbytes ); - # maxbytes "mint_release" string => "$(mint_info[RELEASE][1])"; "mint_codename" string => "$(mint_info[CODENAME][1])";