.. _lineinfile: lineinfile `````````````````````````````` .. versionadded:: 0.7 This module will search a file for a line, and ensure that it is present or absent. This is primarily useful when you want to change a single line in a file only. For other cases, see the ``copy`` or ``template`` modules. .. raw:: html
parameter | required | default | choices | comments |
---|---|---|---|---|
state | False | present |
|
Whether the line should be there or not. |
name | True | The file to modify | ||
insertafter | False | EOF |
|
Used with state=present. If specified, the line will be inserted after the specified regular expression. Two special values are available; BOF for inserting the line at the beginning of the file, and EOF for inserting the line at the end of the file. |
regexp | True | The regular expression to look for in the file. For state=present, the pattern to replace. For state=absent, the pattern of the line to remove. | ||
line | False | Required for state=present. The line to insert/replace into the file. Must match the value given to regexp . |
||
backup | False | False | Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly. |
lineinfile name=/etc/selinux/config regexp=^SELINUX= line=SELINUX=disabled
lineinfile name=/etc/sudoers state=absent regexp="^%wheel"