replace

Collection: builtin

Full Name: parallax.builtin.replace

Aliases: ansible.builtin.replace, replace

Synopsis

Manage replace

Parameters

NameTypeRequiredDefaultDescription
pathstringyesPath to the file to modify (alias: dest, destfile, name)
regexpstringyesRegular expression pattern to search for
replacestringReplacement string (if omitted, matching lines are removed)
backupboolfalseCreate a backup file including timestamp information
encodingstringutf-8encoding used for reading and writing the file
validatestringvalidate the file using a command
multilineboolfalseEnable multiline mode (^ and $ match line boundaries)
dotallboolfalseEnable dotall mode (. matches newlines)
ignorecaseboolfalseEnable case-insensitive matching
beforestringIf specified, only content before this pattern will be replaced
afterstringIf specified, only content after this pattern will be replaced
othersstringignoreignore, warn, or fail
ownerstringName of the user that should own the file
groupstringName of the group that should own the file
modestringThe permissions the resulting file should have
attributesstringThe attributes the resulting file should have
seuserstringThe user part of the SELinux file context
serolestringThe role part of the SELinux file context
setypestringThe type part of the SELinux file context
selevelstringThe level part of the SELinux file context
unsafe_writesboolfalseAllow unsafe file operations
deststringalias for path
destfilestringalias for path
namestringalias for path

Example

- name: Example replace task
  replace:
    path: <your_path>
    regexp: <your_regexp>