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
68 changes: 38 additions & 30 deletions example_def.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
{
"classes":
{
"my_apache": [ "server1", "server2", "redhat.*" ],
"my_other_apache": [ "server[34]", "debian.*" ],
"my_filehost": [ "server3" ],
"my_gateway": [ "server3" ],
"my_yum_role": [ "redhat.*" ],
"my_redhat_role": [ "redhat.*" ],
"my_apt_role": [ "debian.*" ],
"my_debian_role": [ "debian.*" ],
"services_autorun": [ "any" ],
"cfengine_internal_disable_agent_email": [ "enterprise_edition" ],
"cfe_internal_core_watchdog_enabled": [ "any" ],
"mpf_control_agent_default_repository": [ "any" ]
},

"inputs": [ "$(sys.libdir)/bundles.cf" ],
"vars": {

"control_agent_default_repository": "/var/cfengine/edit_backups",
"acl": [ ".*$(def.domain)", "$(sys.policy_hub)/16" ],
"control_agent_maxconnections": 100,
"control_common_bundlesequence_end": [ "my_bundle", "my_other_bundle" ],
"control_agent_files_single_copy": [ "/etc/.*", "/tmp/special_file" ],
"input_name_patterns": [ ".*\\.cf",".*\\.dat",".*\\.txt", ".*\\.conf", ".*\\.mustache",
".*\\.sh", ".*\\.pl", ".*\\.py", ".*\\.rb",
"cf_promises_release_id", ".*\\.json", ".*\\.yaml", ".*\\.js" ],

"dir_templates": "/var/cfengine/templates_tests"
}
"classes": {
"my_apache": ["server1", "server2", "redhat.*"],
"my_other_apache": ["server[34]", "debian.*"],
"my_filehost": ["server3"],
"my_gateway": ["server3"],
"my_yum_role": ["redhat.*"],
"my_redhat_role": ["redhat.*"],
"my_apt_role": ["debian.*"],
"my_debian_role": ["debian.*"],
"services_autorun": ["any"],
"cfengine_internal_disable_agent_email": ["enterprise_edition"],
"cfe_internal_core_watchdog_enabled": ["any"],
"mpf_control_agent_default_repository": ["any"]
},
"inputs": ["$(sys.libdir)/bundles.cf"],
"vars": {
"control_agent_default_repository": "/var/cfengine/edit_backups",
"acl": [".*$(def.domain)", "$(sys.policy_hub)/16"],
"control_agent_maxconnections": 100,
"control_common_bundlesequence_end": ["my_bundle", "my_other_bundle"],
"control_agent_files_single_copy": ["/etc/.*", "/tmp/special_file"],
"input_name_patterns": [
".*\\.cf",
".*\\.dat",
".*\\.txt",
".*\\.conf",
".*\\.mustache",
".*\\.sh",
".*\\.pl",
".*\\.py",
".*\\.rb",
"cf_promises_release_id",
".*\\.json",
".*\\.yaml",
".*\\.js"
],
"dir_templates": "/var/cfengine/templates_tests"
}
}
3 changes: 3 additions & 0 deletions inventory/any.cf
Original file line number Diff line number Diff line change
Expand Up @@ -1417,8 +1417,10 @@ body package_method inventory_lslpp(update_interval)
package_list_update_command => "/usr/bin/true";
package_list_update_ifelapsed => $(update_interval);
package_list_command => "/usr/bin/lslpp -Lqc";

# list RPMs too
package_list_version_regex => "[^:]+:[^:]+:([^:]+):.*";

# Make sure version is not included in the name, that indicates RPM
# packages, which we should ignore.
package_list_name_regex => "[^:]+:(([^-:]|-[^0-9])+):.*";
Expand Down Expand Up @@ -1483,5 +1485,6 @@ body contain inventory_in_shell
# Copy of `in_shell`, which see.
{
useshell => "true";

# canonical "useshell" but this is backwards-compatible
}
1 change: 1 addition & 0 deletions services/main.cf
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ bundle agent mpf_main
# User Defined Service Catalogue
{
methods:

# Activate your custom policies here
}
Original file line number Diff line number Diff line change
@@ -1,59 +1,72 @@
# Tests that the bundles specified in vars control_common_bundlesequence_end
# are automatically run.

body common control
{
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

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

bundle agent test
{
vars:
# This is bad, see below.
"files_to_copy" slist => {
"cfe_internal",
"controls",
"inventory",
"lib",
"promises.cf",
"services",
# This is bad, see below.
"files_to_copy"
slist => {
"cfe_internal",
"controls",
"inventory",
"lib",
"promises.cf",
"services",
};

files:
"$(sys.inputdir)/."
create => "true";
# Ideally this should be a complete subdir copy, but masterfiles files are
# currently mixed with other files, including this directory that we're
# in, so we would get an infinitely deep copy in that case.
"$(sys.inputdir)/$(files_to_copy)"
copy_from => dcs_sync("$(this.promise_dirname)/../../../../$(files_to_copy)"),
perms => m(600),
depth_search => recurse("inf");
"$(sys.inputdir)/." create => "true";

# Ideally this should be a complete subdir copy, but masterfiles files are
# currently mixed with other files, including this directory that we're
# in, so we would get an infinitely deep copy in that case.
"$(sys.inputdir)/$(files_to_copy)"
copy_from => dcs_sync(
"$(this.promise_dirname)/../../../../$(files_to_copy)"
),
perms => m(600),
depth_search => recurse("inf");

methods:
"" usebundle => file_make("$(sys.inputdir)/secondary.cf", '
""
usebundle => file_make(
"$(sys.inputdir)/secondary.cf",
'
bundle agent x
{
reports:
"reporting actuation of bundle x";
}
');
'
);

"" usebundle => file_copy("$(this.promise_filename).json", "$(sys.inputdir)/def.json");
""
usebundle => file_copy(
"$(this.promise_filename).json", "$(sys.inputdir)/def.json"
);
}

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

bundle agent check
{
vars:
#"command" string => "$(sys.cf_agent) -Kf $(sys.inputdir)/promises.cf|$(G.grep) 'R:'";
"command" string => "$(sys.cf_agent) -Kf $(sys.inputdir)/promises.cf";

methods:
"" usebundle => dcs_passif_output(".*R: reporting actuation of bundle x.*", "", $(command), $(this.promise_filename));
""
usebundle => dcs_passif_output(
".*R: reporting actuation of bundle x.*",
"",
$(command),
$(this.promise_filename)
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"inputs": [ "$(sys.inputdir)/secondary.cf" ],

"vars": {
"control_common_bundlesequence_end": [ "x" ]
}
"inputs": ["$(sys.inputdir)/secondary.cf"],
"vars": { "control_common_bundlesequence_end": ["x"] }
}
68 changes: 41 additions & 27 deletions tests/acceptance/00_basics/def.json/inputs.cf
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,72 @@
# Heavily inspired by the inputs.cf test in core. The key difference is that
# this test does not explicitly refer to the variable defined in def.json, but
# relies on the masterfiles policies to do it.

body common control
{
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
inputs => { "../../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

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

bundle agent test
{
vars:
# This is bad, see below.
"files_to_copy" slist => {
"cfe_internal",
"controls",
"inventory",
"lib",
"promises.cf",
"services",
# This is bad, see below.
"files_to_copy"
slist => {
"cfe_internal",
"controls",
"inventory",
"lib",
"promises.cf",
"services",
};

files:
"$(sys.inputdir)/."
create => "true";
# Ideally this should be a complete subdir copy, but masterfiles files are
# currently mixed with other files, including this directory that we're
# in, so we would get an infinitely deep copy in that case.
"$(sys.inputdir)/$(files_to_copy)"
copy_from => dcs_sync("$(this.promise_dirname)/../../../../$(files_to_copy)"),
depth_search => recurse("inf");
"$(sys.inputdir)/." create => "true";

# Ideally this should be a complete subdir copy, but masterfiles files are
# currently mixed with other files, including this directory that we're
# in, so we would get an infinitely deep copy in that case.
"$(sys.inputdir)/$(files_to_copy)"
copy_from => dcs_sync(
"$(this.promise_dirname)/../../../../$(files_to_copy)"
),
depth_search => recurse("inf");

methods:
"" usebundle => file_make("$(sys.inputdir)/secondary.cf", '
""
usebundle => file_make(
"$(sys.inputdir)/secondary.cf",
'
bundle common x
{
classes:
"test_class_4f862c89e9bc62fa6da0ca3c782678893c0dc246" expression => "any";
}
');
'
);

"" usebundle => file_copy("$(this.promise_filename).json", "$(sys.inputdir)/def.json");
""
usebundle => file_copy(
"$(this.promise_filename).json", "$(sys.inputdir)/def.json"
);
}

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

bundle agent check
{
vars:
"command" string => "$(sys.cf_promises) --show-classes -f $(sys.inputdir)/promises.cf|$(G.grep) test_class";
"command"
string => "$(sys.cf_promises) --show-classes -f $(sys.inputdir)/promises.cf|$(G.grep) test_class";

methods:
"" usebundle => dcs_passif_output("test_class_4f862c89e9bc62fa6da0ca3c782678893c0dc246\s+source=promise", "", $(command), $(this.promise_filename));
""
usebundle => dcs_passif_output(
"test_class_4f862c89e9bc62fa6da0ca3c782678893c0dc246\s+source=promise",
"",
$(command),
$(this.promise_filename)
);
}
2 changes: 1 addition & 1 deletion tests/acceptance/00_basics/def.json/inputs.cf.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"inputs": [ "$(sys.inputdir)/secondary.cf" ]
"inputs": ["$(sys.inputdir)/secondary.cf"]
}
Loading
Loading