Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
5a75433c
Commit
5a75433c
authored
Sep 19, 2012
by
Jan-Piet Mens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added DOCUMENTATION to lineinfile module
parent
b8c4bb9e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
library/lineinfile
+53
-0
No files found.
library/lineinfile
View file @
5a75433c
...
...
@@ -21,6 +21,59 @@
import
re
import
os
DOCUMENTATION
=
'''
---
module: lineinfile
short_description: Ensure a particular line is in a file
description:
- 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 M(copy) or M(template) modules.
version_added: "0.7"
options:
- name:
required: true
description:
- The file to modify
- regexp:
required: true
description:
- The regular expression to look for in the file. For I(state=present),
the pattern to replace. For I(state=absent), the pattern of the line
to remove.
- state:
required: false
choices: [ present, absent ]
default: "present"
aliases: []
description:
- Whether the line should be there or not.
- line:
required: false
description:
- Required for I(state=present). The line to insert/replace into the
file. Must match the value given to C(regexp).
- insertafter:
required: false
default: EOF
description:
- Used with I(state=present). If specified, the line will be inserted
after the specified regular expression. Two special values are
available; C(BOF) for inserting the line at the beginning of the
file, and C(EOF) for inserting the line at the end of the file.
choices: [ BOF, EOF ]
default: EOF
- backup:
required: false
default: no
description:
- Create a backup file including the timestamp information so you can
get the original file back if you somehow clobbered it incorrectly.
examples:
- code: lineinfile name=/etc/selinux/config regexp=^SELINUX= line=SELINUX=disabled
- code: lineinfile name=/etc/sudoers state=absent regexp="^
%
wheel"
'''
def
present
(
module
,
name
,
regexp
,
line
,
insertafter
,
backup
):
f
=
open
(
name
,
'rb'
)
lines
=
f
.
readlines
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment