file_content
Enforce the content of a file.
⚙️ Compatible targets: Linux, Windows
Parameters
Name | Documentation |
---|---|
path | File name to edit (absolute path on the target node). This parameter is required. |
lines | Line(s) to add in the file - if lines is a list, please use @{lines} to pass the iterator rather than iterating over each values. This parameter is required. |
enforce | Enforce the file to contain only line(s) defined (true or false). Choices:
This parameter is required. |
Outcome conditions
You need to replace ${path}
with its actual canonified value.
- ✅ Ok:
file_lines_present_${path}_ok
- ☑️ Already compliant:
file_lines_present_${path}_kept
- 🟨 Repaired:
file_lines_present_${path}_repaired
- ☑️ Already compliant:
- ❌ Error:
file_lines_present_${path}_error
Example
method: file_content
params:
path: VALUE
lines: VALUE
enforce: 'true'
Documentation
Enforce the content of a file. The enforce parameter changes the edition method:
- If enforce is set to true the file content will be forced
- If enforce is set to false the file content will be forced line by line. Which means that each line managed can not be duplicated and the order will not be guaranteed.
In most cases, the enforce parameter should be set to true. When enforce is set to false, and the managed lines are:
Bob
Alice
Charly
Will be compliant with the following file contents:
Bob
Alice
Charly
Charly
Bob
Alice
Charly
Bob
Charly
Alice