file_ensure_key_value_parameter_not_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

⚠️ Deprecated: This method is deprecated and should not be used.

Parameters

NameDocumentation
pathFile name to edit (absolute path on the target node).

This parameter is required.
keyFull key name.

This parameter is required.
key_value_separatorcharacter used to separate key and value in a key-value line.

This parameter can contain only whitespaces.
This parameter is required.
parameter_regexRegular 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_separatorCharacter used to separate parameters in the list.

This parameter can contain only whitespaces.
This parameter is required.
leading_char_separatorleading character of the parameters.

This parameter is optional.
closing_char_separatorclosing character of the parameters.

This parameter is optional.

Outcome conditions

You need to replace ${path} with its actual canonified value.

  • ✅ Ok: file_ensure_key_value_parameter_not_in_list_${path}_ok
    • ☑️ Already compliant: file_ensure_key_value_parameter_not_in_list_${path}_kept
    • 🟨 Repaired: file_ensure_key_value_parameter_not_in_list_${path}_repaired
  • ❌ Error: file_ensure_key_value_parameter_not_in_list_${path}_error

Example

method: file_ensure_key_value_parameter_not_in_list
params:
  path: VALUE
  closing_char_separator: OPTIONAL_VALUE
  parameter_regex: VALUE
  key_value_separator: VALUE
  parameter_separator: VALUE
  leading_char_separator: OPTIONAL_VALUE
  key: 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", " ", "\"", "\"");