Parameter |
Choices/Defaults |
Comments |
backrefs
bool |
|
Used with state=present . If set, line can contain backreferences (both positional and named) that will get populated if the regexp matches. This flag changes the operation of the module slightly; insertbefore and insertafter will be ignored, and if the regexp doesn't match anywhere in the file, the file will be left unchanged.
If the regexp does match, the last matching line will be replaced by the expanded line parameter.
|
backup
bool |
|
Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.
|
create
bool |
|
Used with state=present . If specified, the file will be created if it does not already exist. By default it will fail if the file is missing.
|
encoding
|
Default:
"auto"
|
Specifies the encoding of the source text file to operate on (and thus what the output encoding will be). The default of auto will cause the module to auto-detect the encoding of the source file and ensure that the modified file is written with the same encoding.
This is mostly useful with create=yes if you want to create a new file with a specific encoding. If create=yes is specified without a specific encoding, the default encoding (UTF-8, no BOM) will be used.
|
insertafter
|
|
Used with state=present . If specified, the line will be inserted after the last match of specified regular expression. A special value is available; EOF for inserting the line at the end of the file.
If specified regular expression has no matches, EOF will be used instead. May not be used with backrefs .
|
insertbefore
|
|
Used with state=present . If specified, the line will be inserted before the last match of specified regular expression. A value is available; BOF for inserting the line at the beginning of the file.
If specified regular expression has no matches, the line will be inserted at the end of the file. May not be used with backrefs .
|
line
|
|
Required for state=present . The line to insert/replace into the file. If backrefs is set, may contain backreferences that will get expanded with the regexp capture groups if the regexp matches.
Be aware that the line is processed first on the controller and thus is dependent on yaml quoting rules. Any double quoted line will have control characters, such as '\r\n', expanded. To print such characters literally, use single or no quotes.
|
newline
|
|
Specifies the line separator style to use for the modified file. This defaults to the windows line separator (\r\n ). Note that the indicated line separator will be used for file output regardless of the original line separator that appears in the input file.
|
path
required |
|
The path of the file to modify.
Note that the Windows path delimiter \ must be escaped as \\ when the line is double quoted.
Before 2.3 this option was only usable as dest, destfile and name.
aliases: dest, destfile, name
|
regexp
|
|
|
state
|
Choices:
- absent
present ←
|
Whether the line should be there or not.
|
validate
|
|
Validation to run before copying into place. Use %s in the command to indicate the current file to validate.
The command is passed securely so shell features like expansion and pipes won't work.
|