Forum: Cfengine Help
Subject: execresult will look for binaries even though bundle is not included
Author: filbranden
Link to topic: https://cfengine.com/forum/read.php?3,18117,18117#msg-18117

Hi,

I have several bundles and some of them use "execresult" in vars: section to 
look up system components. In some cases, I want to avoid including those 
bundles in machines that do not have those binaries, however, I noticed that 
the "vars:" section seems to be executed (or at least the existence of the 
execresult file checked) even though it is not included.

Example test.cf file:


body common control {
        bundlesequence => {
          "common_config",
          "all_test_bundles"
        };
}

bundle common common_config {
classes:
        "host_has_command_xyz123" or => { "hosts", "that", "have", "this", 
"command" };
}

bundle agent all_test_bundles {
methods:
    host_has_command_xyz123::
        "any" usebundle => test_bundle_that_uses_xyz123;
    any::
        "any" usebundle => test_bundle_generic;
}

bundle agent test_bundle_that_uses_xyz123 {
vars:
        "xyz123_output" string => execresult("/opt/xyz123/bin/xyz123 
--verbose", "noshell");
reports:
        cfengine_3::
                "xyz123 was run, output = $(xyz123_output)";
}

bundle agent test_bundle_generic {
reports:
        cfengine_3::
                "generic test bundle was run";
}



If I run it on a machine that has xyz123 binary:

$ cf-agent -K -Dthat -f test.cf
R: xyz123 was run, output = hello world
R: generic test bundle was run


If I run it on a machine that has xyz123 binary but that is not one of the 
hosts where it's supposed to run:

$ cf-agent -K -f test.cf
R: generic test bundle was run


But if I run it on a machine that does not have that binary:

$ cf-agent -K -f test.cf
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
Proposed executable file "/opt/xyz123/bin/xyz123" doesn't exist
ExecResult "noshell" is assumed to be executable but isn't
R: generic test bundle was run


How can I prevent cf-agent of evaluating those "execresult" statments in 
"vars:" sections of bundles that I don't intend to include?

Thanks!

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to