file_report_content

Report the content of a file.

⚙️ Compatible targets: Linux

Parameters

NameDocumentation
pathFile to report content from.

This parameter is required.
regexRegex to search in the file (empty for whole file).

This parameter is optional.
contextNumber of context lines when matching regex (default is 0).

This parameter must match ^\d*$.
This parameter is optional.

Outcome conditions

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

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

Example

method: file_report_content
params:
  regex: OPTIONAL_VALUE
  path: VALUE
  context: OPTIONAL_VALUE

Documentation

Report the content of a file.

This method does nothing on the system, but only reports a complete or partial content from a given file. This allows centralizing this information on the server, and avoid having to connect on each node to get this information.

NOTE: This method only works in "Full Compliance" reporting mode.

Parameters

Target

This is the file you want to report content from. The method will return an error if it does not exist.

Regex

If empty, the method will report the whole file content. If set, the method will grep the file for the given regular expression, and report the result.

Context

When specifying a regex, will add the number of lines of context around matches (default is 0, i.e. no context).

When reporting the whole file, this parameter is ignored.

Examples

# To get the whole /etc/hosts content
file_report_content("/etc/hosts", "", "");
# To get lines starting by "nameserver" in /etc/resolv.conf
file_report_content("/etc/resolv.conf", "^nameserver", "");
# To get lines containing "rudder" from /etc/hosts with 3 lines of context
file_report_content("/etc/hosts", "rudder", "3");