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
17 changes: 8 additions & 9 deletions content/examples/example-snippets/aborting_execution.cf
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
body common control
{
bundlesequence => { "testbundle" };
version => "1.2.3";
bundlesequence => { "testbundle" };
version => "1.2.3";
}
###########################################

body agent control
{
abortbundleclasses => { "invalid.Hr16" };
abortbundleclasses => { "invalid.Hr16" };
}
###########################################

bundle agent testbundle
{
vars:
"userlist" slist => { "xyz", "mark", "jeang", "jonhenrik", "thomas", "eben" };
"userlist"
slist => { "xyz", "mark", "jeang", "jonhenrik", "thomas", "eben" };

methods:
"any" usebundle => subtest("$(userlist)");
"any" usebundle => subtest("$(userlist)");
}
###########################################

bundle agent subtest(user)
{
classes:
"invalid" not => regcmp("[a-z][a-z][a-z][a-z]","$(user)");
"invalid" not => regcmp("[a-z][a-z][a-z][a-z]", "$(user)");

reports:
!invalid::
"User name $(user) is valid at 4 letters";

invalid::
"User name $(user) is invalid";
}
29 changes: 13 additions & 16 deletions content/examples/example-snippets/acl_file_example.cf
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
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_directory_inherit => "parent";
aces => { "user:*:r(wwx),-r:allow", "group:*:+rw:allow", "mask:x:allow", "all:r"};
acl_method => "overwrite";
acl_type => "posix";
acl_directory_inherit => "parent";
aces => {
"user:*:r(wwx),-r:allow", "group:*:+rw:allow", "mask:x:allow", "all:r"
};
}
#########################################

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

body depth_search include_base
{
include_basedir => "true";
include_basedir => "true";
}
14 changes: 5 additions & 9 deletions content/examples/example-snippets/acl_generic_example.cf
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
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 => test;
}
#########################################

body acl test
{
acl_type => "generic";
aces => {"user:bob:rwx", "group:staff:rx", "all:r"};
acl_type => "generic";
aces => { "user:bob:rwx", "group:staff:rx", "all:r" };
}
#########################################

body depth_search include_base
{
include_basedir => "true";
include_basedir => "true";
}
17 changes: 7 additions & 10 deletions content/examples/example-snippets/acl_secret_example.cf
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
body common control
{
bundlesequence => { "acls" };
bundlesequence => { "acls" };
}
#########################################

bundle agent acls
{
files:
windows::
"c:\Secret"
acl => win,
depth_search => include_base,
comment => "Secure the secret directory from unauthorized access";
acl => win,
depth_search => include_base,
comment => "Secure the secret directory from unauthorized access";
}
#########################################

body acl win
{
acl_method => "overwrite";
aces => { "user:Administrator:rwx" };
acl_method => "overwrite";
aces => { "user:Administrator:rwx" };
}
#########################################

body depth_search include_base
{
include_basedir => "true";
include_basedir => "true";
}
47 changes: 25 additions & 22 deletions content/examples/example-snippets/active_directory_example.cf
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,43 @@
# to the resources we want to read.
#
#########################################################################

bundle agent active_directory
{
vars:
# NOTE: Edit this to your domain, e.g. "corp", may also need more DC's after it
"domain_name" string => "cftesting";
"user_name" string => "Guest";


# NOTE: We can also extract data from remote Domain Controllers
# NOTE: Edit this to your domain, e.g. "corp", may also need more DC's after it
"domain_name" string => "cftesting";
"user_name" string => "Guest";

# NOTE: We can also extract data from remote Domain Controllers
dummy.DomainController::
"domain_controller" string => "localhost";
"domain_controller" string => "localhost";

"userlist"
slist => ldaplist(
"ldap://$(domain_controller)",
"CN=Users,DC=$(domain_name),DC=com",
"(objectClass=user)",
"sAMAccountName",
"subtree",
"none"
);

"userlist" slist => ldaplist(
"ldap://$(domain_controller)",
"CN=Users,DC=$(domain_name),DC=com",
"(objectClass=user)",
"sAMAccountName",
"subtree",
"none");
classes:
dummy.DomainController::
"gotuser" expression => ldaparray(
"userinfo",
"ldap://$(domain_controller)",
"CN=$(user_name),CN=Users,DC=$(domain_name),DC=com",
"(name=*)",
"subtree",
"none");
"gotuser"
expression => ldaparray(
"userinfo",
"ldap://$(domain_controller)",
"CN=$(user_name),CN=Users,DC=$(domain_name),DC=com",
"(name=*)",
"subtree",
"none"
);

reports:
dummy.DomainController::
'Username is "$(userlist)"';

dummy.gotuser::
"Got user data; $(userinfo[name]) has logged on $(userinfo[logonCount]) times";
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
# Note: Anonymous LDAP binding must be allowed, and the Anonymous user
# must have read access to CN=Users and CN=theusername
# Run the agent in verbose mode to see the data

bundle agent ldap
{
classes:
"gotdata" expression => ldaparray(
"myarray",
"ldap://cf-win2003",
"CN=Test Pilot,CN=Users,DC=domain,DC=cf-win2003",
"(name=*)",
"subtree",
"none");
"gotdata"
expression => ldaparray(
"myarray",
"ldap://cf-win2003",
"CN=Test Pilot,CN=Users,DC=domain,DC=cf-win2003",
"(name=*)",
"subtree",
"none"
);

reports:
gotdata::
"Got user data";

!gotdata::
"Did not get user data";
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# List users from Active Directory through LDAP
# Note: Anonymous LDAP binding must be allowed, and the Anonymous user
# must have read access to CN=Users

bundle agent ldap
{
vars:
"userlist" slist => ldaplist(
"ldap://cf-win2003",
"CN=Users,DC=domain,DC=cf-win2003",
"(objectClass=user)",
"sAMAccountName",
"subtree",
"none");
"userlist"
slist => ldaplist(
"ldap://cf-win2003",
"CN=Users,DC=domain,DC=cf-win2003",
"(objectClass=user)",
"sAMAccountName",
"subtree",
"none"
);

reports:
'Username: "$(userlist)"';
'Username: "$(userlist)"';
}
11 changes: 5 additions & 6 deletions content/examples/example-snippets/add_lines_to_a_file.cf
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
body common control
{
any::
bundlesequence => { "insert" };
any::
bundlesequence => { "insert" };
}
#######################################################

bundle agent insert
{
vars:
"lines" string =>
"
"lines"
string => "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was worried for a second that this one changed the fundamental string, but no, looks good.

One potato
Two potato
Three potatoe
Four
";

files:
"/tmp/test_insert"
"/tmp/test_insert"
create => "true",
edit_line => append_if_no_line("$(insert.lines)");
}
10 changes: 4 additions & 6 deletions content/examples/example-snippets/add_lines_to_a_file_1.cf
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
body common control
{
any::
bundlesequence => { "insert" };
any::
bundlesequence => { "insert" };
}
#######################################################

bundle agent insert
{
vars:
"lines" slist => { "One potato", "Two potato",
"Three potatoe", "Four" };
"lines" slist => { "One potato", "Two potato", "Three potatoe", "Four" };

files:
"/tmp/test_insert"
"/tmp/test_insert"
create => "true",
edit_line => append_if_no_line("@(insert.lines)");
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
#
# Package management
#

body common control
{
inputs => { "$(sys.libdir)/packages.cf" }
bundlesequence => { "packages" };
inputs => { "$(sys.libdir)/packages.cf" }
bundlesequence => { "packages" };
}
#############################################

bundle agent packages
{
vars:
"match_package" slist => {
"apache2",
"apache2-mod_php5",
"apache2-prefork",
"php5"
};
"match_package"
slist => { "apache2", "apache2-mod_php5", "apache2-prefork", "php5" };

packages:
solaris::
"$(match_package)"
package_policy => "add",
package_method => solaris;
package_policy => "add",
package_method => solaris;

redhat|SuSE::
"$(match_package)"
package_policy => "add",
package_method => yum_rpm;
package_policy => "add",
package_method => yum_rpm;

methods:
# equivalent in 3.6, no OS choices
"" usebundle => ensure_present($(match_package));
# equivalent in 3.6, no OS choices
"" usebundle => ensure_present($(match_package));
}
Loading
Loading