osCheck-1.7.0
2 minute read
KOSI Plugin osCheck Version 1.7.0
Summary
The osCheck
plugin is used to detect the operating system name and version on which the plugin is executed. This information is stored in temporary variables, making it available for use by other plugins, such as fPrint
. By utilizing osCheck
, users can dynamically access OS details within their KOSI packages, enabling better system-specific configurations and logging.
Keys
Key | Description | |
---|---|---|
getOSVar | Mandatory | Set a variable name in which the OS name should be stored. |
getOSVersionVar | Mandatory | Set a variable name in which the OS version should be stored. |
Examples
Example 1
In the example below, the OS name will be stored in the temporary variable os
, and the version name in the variable version
. The fprint
plugin has been added to generate console output, displaying the detected OS name and version.
languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-example-packagev3";
description = "kosi-example-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input = "template.yaml";
}
containers =
{
example = ["docker.io", "nginx", "latest"];
}
install
{
osCheck
(
getOSVar = "os";
getOSVersionVar = "version";
);
fprint
(
message = "The OS system is {0} in version {1}.";
variables = "[os,version]"
);
}
Expected Output
2025-01-31 16:56:23 Info: KOSI version: 2.11.3.0_1734015070
2025-01-31 16:56:24 Info: The OS system is Red Hat Enterprise Linux in version 8.9.
2025-01-31 16:56:24 Info: Installation successful.
Example 2
Using osCheck
with the if
and print
plugins
This example shows the interaction of several plug-ins.
In this example, we use the osCheck
plugin together with the if
and print
plugins to check the condition whether it is the correct operating system and output a message accordingly:
languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-example-oscheck-if";
description = "Example using oscheck with if";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input = "template.yaml";
}
install
{
osCheck
(
getOSVar = "os";
getOSVersionVar = "version";
);
if (condition="$os$ = 'Red Hat Enterprise Linux'") then
{
print(message = "This is the expected OS.");
}
else
{
print(message = "Wrong OS.");
}
}
Expected Output
If os
is ‘Red Hat Enterprise Linux’:
2025-02-26 15:18:28 Info: This is the expected OS.
Otherwise:
2025-02-26 15:18:28 Info: Wrong OS.