1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#######################################################
#
# Test powershell class
#
#######################################################
body common control
{
inputs => { "../../default.cf.sub" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}
#######################################################
bundle agent init
{
vars:
"dummy" string => "dummy";
}
#######################################################
bundle agent test
{
meta:
"test_soft_fail" string => "windows",
meta => { "ENT-10257" };
vars:
"dummy" string => "dummy";
}
#######################################################
bundle agent check
{
classes:
"ok" and => { "!windows", "!powershell" };
# This relies on powershell being in the path, which it should be for a standard install.
"detected_powershell" expression => regcmp(".*Succeeded.*", execresult("powershell Get-Content $(G.cwd)$(const.dirsep)text.txt", "useshell"));
"ok" and => { "windows", "powershell", "detected_powershell" };
"ok" and => { "windows", "!powershell", "!detected_powershell" };
reports:
DEBUG.windows.powershell.!detected_powershell::
"Powershell was detected by CFEngine, but not by the test.";
DEBUG.windows.!powershell.detected_powershell::
"Powershell was detected by the test, but not by CFEngine.";
DEBUG.windows.powershell.detected_powershell::
"Powershell was detected by CFEngine and the test.";
DEBUG.windows.!powershell.!detected_powershell::
"Powershell was not detected by the test, nor by CFEngine.";
DEBUG.!windows.powershell::
"Powershell was detected on a non-Windows system.";
ok::
"$(this.promise_filename) Pass";
!ok::
"$(this.promise_filename) FAIL";
}
|