Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions cfe_internal/CFE_cfengine.cf
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Comment thread
olehermanse marked this conversation as resolved.
"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
Expand All @@ -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
Comment thread
olehermanse marked this conversation as resolved.
"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::
Expand Down
55 changes: 23 additions & 32 deletions inventory/aix.cf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,65 +13,57 @@ 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.";

"$(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)";
}
132 changes: 85 additions & 47 deletions inventory/debian.cf
Original file line number Diff line number Diff line change
Expand Up @@ -5,88 +5,126 @@ 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",
Comment thread
olehermanse marked this conversation as resolved.
# array to populate
"$(linuxmint_info)",
Comment on lines +20 to +21
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think comments should stay on the side if that's where they where. At least, that's how black works

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really possible - comments are just comments and we render from syntax tree - whitespace is lost.

(We'd have to change the parser and architecture quite a bit to achieve that, and I don't think it's really worth it).

# 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
# to ensure that the mint_info array has been evaluated as well.
# 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";
}
6 changes: 4 additions & 2 deletions inventory/suse.cf
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
}
9 changes: 4 additions & 5 deletions lib/users.cf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -20,6 +19,6 @@ body password hashed_password(hash)
#
# **See also:** `plaintext_password()`
{
format => "hash";
data => $(hash);
format => "hash";
data => $(hash);
}
Loading