blockinfile

Collection: builtin

Full Name: parallax.builtin.blockinfile

Aliases: ansible.builtin.blockinfile, blockinfile

Synopsis

Manage blockinfile

Parameters

NameTypeRequiredDefaultDescription
pathstringyesPath to the file to modify (alias: dest, destfile, name)
blockstringtext content to insert/update/remove in the block
statestringpresentpresent or absent state for the block, Choices: present and absent
markerstring# {mark} ANSIBLE MANAGED BLOCKTemplate for the block markers
marker_beginstringBEGINMarker text for the beginning of the block
marker_endstringENDMarker text for the end of the block
insertafterstringInsert block after this line
insertbeforestringInsert block before this line
createboolfalsecreate the destination if it does not exist as a new file
backupboolfalseCreate backup file with timestamp
validatestringvalidate the file after changes using a command
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 blockinfile task
  blockinfile:
    path: <your_path>