lineinfile

Collection: builtin

Full Name: parallax.builtin.lineinfile

Aliases: ansible.builtin.lineinfile, lineinfile

Synopsis

Manage lineinfile

Parameters

NameTypeRequiredDefaultDescription
pathstringyesThe file to modify
statestringpresentWhether the line should be present or absent
linestringThe line to insert/replace
regexpstringRegular expression to match lines
search_stringstringLiteral string to match in lines
createboolfalseCreate file if it doesn’t exist
backupboolfalseCreate backup of original file
insertafterstringInsert line after matching regex
insertbeforestringInsert line before matching regex
firstmatchboolfalseUse first regex match
backrefsboolfalseUse regex backreferences
ownerstringFile owner
groupstringFile group
modestringFile permissions
validatestringCommand to validate file before saving

Example

- name: Example lineinfile task
  lineinfile:
    path: <your_path>