Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion contrib/masterfiles/git-failsafe.cf
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ bundle agent git_update
perms => u_m("755"),
depth_search => u_recurse_basedir("inf"),
action => u_immediate,
ifvarclass => "hpux";
if => "hpux";

"/usr/local/bin"
comment => "Ensure cfengine binaries were copied to /usr/local/bin",
Expand Down
36 changes: 12 additions & 24 deletions examples/abort.cf
Original file line number Diff line number Diff line change
@@ -1,59 +1,47 @@
# Copyright 2021 Northern.tech AS

#
# This file is part of CFEngine 3 - written and maintained by Northern.tech AS.

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3.

#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

# To the extent this program is licensed as part of the Enterprise
# versions of Cfengine, the applicable Commercial Open Source License
# (COSL) may apply to this file if you as a licensee so wish it. See
# included file COSL.txt.

#[%+%]
body common control

{
bundlesequence => { "example" };
bundlesequence => { "example" };
}

body agent control

{
abortbundleclasses => { "invalid" };
abortbundleclasses => { "invalid" };
}
#[%-%]

###########################################
#[%+%]

bundle agent example

{
vars:

#"userlist" slist => { "mark", "john" }; # contains all valid entries
"userlist" slist => { "mark", "john", "thomas" }; # contains one invalid entry

#"userlist" slist => { "mark", "john" }; # contains all valid entries
"userlist" slist => { "mark", "john", "thomas" };
# contains one invalid entry
classes:

"invalid" not => regcmp("[a-z][a-z][a-z][a-z]","$(userlist)"); # The class 'invalid' is set if the user name does not
# contain exactly four un-capitalized letters (bundle
# execution will be aborted if set)

"invalid" not => regcmp("[a-z][a-z][a-z][a-z]", "$(userlist)");
# The class 'invalid' is set if the user name does not
# contain exactly four un-capitalized letters (bundle
# execution will be aborted if set)
reports:

!invalid::

"User name $(userlist) is valid at 4 letters";
}
28 changes: 6 additions & 22 deletions examples/accessed_before.cf
Original file line number Diff line number Diff line change
@@ -1,51 +1,35 @@
# Copyright 2021 Northern.tech AS

#
# This file is part of CFEngine 3 - written and maintained by Northern.tech AS.

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3.

#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

# To the extent this program is licensed as part of the Enterprise
# versions of Cfengine, the applicable Commercial Open Source License
# (COSL) may apply to this file if you as a licensee so wish it. See
# included file COSL.txt.

#
# Show the definition of classes by comparing timestamps
#

body common control

{
bundlesequence => { "example" };
bundlesequence => { "example" };
}

###########################################################

bundle agent example

{
{
classes:

"do_it" and => {
accessedbefore("/tmp/earlier","/tmp/later")
};
"do_it" and => { accessedbefore("/tmp/earlier", "/tmp/later") };

reports:

do_it::

"The earlier file has been accessed before the later";

}

13 changes: 5 additions & 8 deletions examples/accessedbefore.cf
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
# Copyright 2021 Northern.tech AS

#
# This file is part of CFEngine 3 - written and maintained by Northern.tech AS.

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3.

#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

# To the extent this program is licensed as part of the Enterprise
# versions of Cfengine, the applicable Commercial Open Source License
# (COSL) may apply to this file if you as a licensee so wish it. See
# included file COSL.txt.

#+begin_src prep
#@ ```
#@ touch -a -t '200102031234.56' /tmp/earlier
Expand All @@ -30,13 +27,13 @@
#+begin_src cfengine3
body common control
{
bundlesequence => { "example" };
bundlesequence => { "example" };
}

bundle agent example
{
classes:
"do_it" expression => accessedbefore("/tmp/earlier","/tmp/later");
"do_it" expression => accessedbefore("/tmp/earlier", "/tmp/later");

reports:
do_it::
Expand Down
43 changes: 13 additions & 30 deletions examples/accumulated_time.cf
Original file line number Diff line number Diff line change
@@ -1,71 +1,54 @@
# Copyright 2021 Northern.tech AS

#
# This file is part of CFEngine 3 - written and maintained by Northern.tech AS.

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3.

#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

# To the extent this program is licensed as part of the Enterprise
# versions of Cfengine, the applicable Commercial Open Source License
# (COSL) may apply to this file if you as a licensee so wish it. See
# included file COSL.txt.

########################################################
#
# Simple test processes
#
########################################################

body common control

{
bundlesequence => { "example" };
bundlesequence => { "example" };
}

########################################################

bundle agent example

{
processes:

".*"

process_count => anyprocs,
process_select => proc_finder;
".*"
process_count => anyprocs,
process_select => proc_finder;

reports:

any_procs::

"Found processes in range";
}

########################################################

body process_select proc_finder

{
ttime_range => irange(accumulated(0,0,0,0,2,0),accumulated(0,0,0,0,20,0));
process_result => "ttime";
ttime_range => irange(
accumulated(0, 0, 0, 0, 2, 0), accumulated(0, 0, 0, 0, 20, 0)
);
process_result => "ttime";
}

########################################################

body process_count anyprocs

{
match_range => "0,0";
out_of_range_define => { "any_procs" };
match_range => "0,0";
out_of_range_define => { "any_procs" };
}

48 changes: 16 additions & 32 deletions examples/acl.cf
Original file line number Diff line number Diff line change
@@ -1,70 +1,54 @@
# Copyright 2021 Northern.tech AS

#
# This file is part of CFEngine 3 - written and maintained by Northern.tech AS.

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3.

#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

# To the extent this program is licensed as part of the Enterprise
# versions of Cfengine, the applicable Commercial Open Source License
# (COSL) may apply to this file if you as a licensee so wish it. See
# included file COSL.txt.


body common control
{
bundlesequence => { "acls" };
bundlesequence => { "acls" };
}

#########################################

bundle agent acls

{
files:

"/media/flash/acl/test_dir"

"/media/flash/acl/test_dir"
depth_search => include_base,
acl => template;
}

#########################################

body acl template

{
acl_method => "overwrite";
acl_type => "posix";
acl_default => "access";
aces => { "user:*:r(wwx),-r:allow", "group:*:+rw:allow", "mask:x:allow", "all:r"};
acl_method => "overwrite";
acl_type => "posix";
acl_default => "access";
aces => {
"user:*:r(wwx),-r:allow", "group:*:+rw:allow", "mask:x:allow", "all:r"
};
}

#########################################

body acl win

{
acl_method => "overwrite";
acl_type => "ntfs";
acl_default => "nochange";
aces => { "user:Administrator:rw", "group:Bad:rwx(Dpo):deny" };
acl_method => "overwrite";
acl_type => "ntfs";
acl_default => "nochange";
aces => { "user:Administrator:rw", "group:Bad:rwx(Dpo):deny" };
}

#########################################

body depth_search include_base

{
include_basedir => "true";
include_basedir => "true";
}
Loading
Loading