file_key_value_parameter_absent_in_list
Ensure that a parameter doesn't exist in a list of parameters, on one single line, in the right hand side of a key->values line.
⚙️ Compatible targets: Linux
Parameters
Name | Documentation |
---|---|
path | File name to edit (absolute path on the target node). This parameter is required. |
key | Full key name. This parameter is required. |
key_value_separator | character used to separate key and value in a key-value line. This parameter can contain only whitespaces. This parameter is required. |
parameter_regex | Regular expression matching the sub-value to ensure is not present in the list of parameters that form the value part of that line. This parameter is required. |
parameter_separator | Character used to separate parameters in the list. This parameter can contain only whitespaces. This parameter is required. |
leading_char_separator | leading character of the parameters. This parameter is optional. |
closing_char_separator | closing character of the parameters. This parameter is optional. |
Outcome conditions
You need to replace ${path}
with its actual canonified value.
- ✅ Ok:
file_key_value_parameter_absent_in_list_${path}_ok
- ☑️ Already compliant:
file_key_value_parameter_absent_in_list_${path}_kept
- 🟨 Repaired:
file_key_value_parameter_absent_in_list_${path}_repaired
- ☑️ Already compliant:
- ❌ Error:
file_key_value_parameter_absent_in_list_${path}_error
Example
method: file_key_value_parameter_absent_in_list
params:
key: VALUE
closing_char_separator: OPTIONAL_VALUE
key_value_separator: VALUE
path: VALUE
parameter_regex: VALUE
parameter_separator: VALUE
leading_char_separator: OPTIONAL_VALUE
Documentation
Edit the file, and ensure it does not contain the defined parameter in the list of values on the right hand side of a key->values line. If the parameter is there, it will be removed. Please note that the parameter can be a regular expression. It will also remove any whitespace character between the parameter and parameter_separator Optionally, you can define leading and closing character to enclose the parameters
Example
If you have an initial file (/etc/default/grub
) containing
GRUB_CMDLINE_XEN="dom0_mem=16G dom0_max_vcpus=32"
To remove parameter dom0_max_vcpus=32
in the right hand side of the line, you'll need the following policy
file_ensure_key_value_parameter_not_in_list("/etc/default/grub", "GRUB_CMDLINE", "=", "dom0_max_vcpus=32", " ", "\"", "\"");